<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic 401 Unauthorized out file while using proc HTTP to access the sharepoint in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/401-Unauthorized-out-file-while-using-proc-HTTP-to-access-the/m-p/787527#M251645</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
options set=SSLREQCERT="allow";

/* for use on Windows and Unix workspace servers */
%let _metauser = %scan(%sysget(METAUSER),1,'@');
/* for use on MVS, Stored Process, and Pooled Workspace servers */
/* %let _metauser = %scan(%sysfunc(getoption(METAUSER)),1,'@'); */
data ids;
  length name $ 16 purpose $ 40;
  label name="Value Name" purpose="Purpose";
  infile datalines dsd;
  input name purpose;
datalines;
SYSUSERID, SAS session host account
_CLIENTUSERID, Windows user ID in SAS EG
_CLIENTUSERNAME, Windows user name in SAS EG
_METAUSER, SAS metadata user ID
run;
proc sql;
  select t1.name,
    t2.value,
    t1.purpose
   from work.ids t1
   inner join sashelp.vmacro t2 on (t1.name = t2.name);
quit;

filename hdrs "/home/headers_sharepoint.txt";
filename Testing "/home/out_sharepoint.txt";
%let Test_URL = "http://spappfarm.intra.net/iapps/SAR/_api/web/lists/GetByTitle('test')/items";
proc http
    url = &amp;amp;Test_URL.
    out = Testing
    method = "get"
	headerout=hdrs
	webusername="S123456"
webpassword="testpassword!!"
webauthdomain="test"
auth_negotiate;
run;



data _null_;
   infile Testing;
   input;
   put _infile_;
run;

data _null_;
   infile hdrs;
   input;
   put _infile_;
run;

%put HTTP Status code = &amp;amp;SYS_PROCHTTP_STATUS_CODE. : &amp;amp;SYS_PROCHTTP_STATUS_PHRASE.; 

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hello Team,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i am trying to execute above proc HTTP code, to access the sharepoint URL to read the lists from it. for some reason am getting the 401 Unauthorized out file .&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. which&amp;nbsp; user from below box , proc HTTP is using for authentication.&lt;/P&gt;
&lt;P&gt;2. what will be fix for this ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;
&lt;DIV id="IDX"&gt;
&lt;TABLE class="table" aria-label="Query Results"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="b header" scope="col"&gt;Value Name&lt;/TH&gt;
&lt;TH class="b header" scope="col"&gt;Macro Variable Value&lt;/TH&gt;
&lt;TH class="b header" scope="col"&gt;Purpose&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="data"&gt;_CLIENTUSERID&lt;/TD&gt;
&lt;TD class="data"&gt;'S123456'&lt;/TD&gt;
&lt;TD class="data"&gt;Windows user ID in SAS EG&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="data"&gt;_CLIENTUSERNAME&lt;/TD&gt;
&lt;TD class="data"&gt;'my name'&lt;/TD&gt;
&lt;TD class="data"&gt;Windows user name in SAS EG&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="data"&gt;_METAUSER&lt;/TD&gt;
&lt;TD class="data"&gt;S123456&lt;/TD&gt;
&lt;TD class="data"&gt;SAS metadata user ID&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="data"&gt;SYSUSERID&lt;/TD&gt;
&lt;TD class="data"&gt;S123456&lt;/TD&gt;
&lt;TD class="data"&gt;SAS session host account&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the out file :&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HTTP/1.1 401 Unauthorized&lt;BR /&gt;Content-Type: text/plain; charset=utf-8&lt;BR /&gt;Server: Microsoft-IIS/8.5&lt;BR /&gt;SPRequestGuid: 6f3e11a0-f343-5019-a75a-65092f2b13f2&lt;BR /&gt;request-id: 6f3e11a0-f343-5019-a75a-65092f2b13f2&lt;BR /&gt;X-FRAME-OPTIONS: SAMEORIGIN&lt;BR /&gt;SPRequestDuration: 2&lt;BR /&gt;SPIisLatency: 0&lt;BR /&gt;WWW-Authenticate: Negotiate&lt;BR /&gt;WWW-Authenticate: NTLM&lt;BR /&gt;X-Powered-By: ASP.NET&lt;BR /&gt;MicrosoftSharePointTeamServices: 15.0.0.4885&lt;BR /&gt;X-Content-Type-Options: nosniff&lt;BR /&gt;X-MS-InvokeApp: 1; RequireReadOnly&lt;BR /&gt;Date: Tue, 28 Dec 2021 15:48:01 GMT&lt;BR /&gt;Content-Length: 16&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 28 Dec 2021 16:06:04 GMT</pubDate>
    <dc:creator>learn_SAS_23</dc:creator>
    <dc:date>2021-12-28T16:06:04Z</dc:date>
    <item>
      <title>401 Unauthorized out file while using proc HTTP to access the sharepoint</title>
      <link>https://communities.sas.com/t5/SAS-Programming/401-Unauthorized-out-file-while-using-proc-HTTP-to-access-the/m-p/787527#M251645</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
options set=SSLREQCERT="allow";

/* for use on Windows and Unix workspace servers */
%let _metauser = %scan(%sysget(METAUSER),1,'@');
/* for use on MVS, Stored Process, and Pooled Workspace servers */
/* %let _metauser = %scan(%sysfunc(getoption(METAUSER)),1,'@'); */
data ids;
  length name $ 16 purpose $ 40;
  label name="Value Name" purpose="Purpose";
  infile datalines dsd;
  input name purpose;
datalines;
SYSUSERID, SAS session host account
_CLIENTUSERID, Windows user ID in SAS EG
_CLIENTUSERNAME, Windows user name in SAS EG
_METAUSER, SAS metadata user ID
run;
proc sql;
  select t1.name,
    t2.value,
    t1.purpose
   from work.ids t1
   inner join sashelp.vmacro t2 on (t1.name = t2.name);
quit;

filename hdrs "/home/headers_sharepoint.txt";
filename Testing "/home/out_sharepoint.txt";
%let Test_URL = "http://spappfarm.intra.net/iapps/SAR/_api/web/lists/GetByTitle('test')/items";
proc http
    url = &amp;amp;Test_URL.
    out = Testing
    method = "get"
	headerout=hdrs
	webusername="S123456"
webpassword="testpassword!!"
webauthdomain="test"
auth_negotiate;
run;



data _null_;
   infile Testing;
   input;
   put _infile_;
run;

data _null_;
   infile hdrs;
   input;
   put _infile_;
run;

%put HTTP Status code = &amp;amp;SYS_PROCHTTP_STATUS_CODE. : &amp;amp;SYS_PROCHTTP_STATUS_PHRASE.; 

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hello Team,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i am trying to execute above proc HTTP code, to access the sharepoint URL to read the lists from it. for some reason am getting the 401 Unauthorized out file .&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. which&amp;nbsp; user from below box , proc HTTP is using for authentication.&lt;/P&gt;
&lt;P&gt;2. what will be fix for this ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;
&lt;DIV id="IDX"&gt;
&lt;TABLE class="table" aria-label="Query Results"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="b header" scope="col"&gt;Value Name&lt;/TH&gt;
&lt;TH class="b header" scope="col"&gt;Macro Variable Value&lt;/TH&gt;
&lt;TH class="b header" scope="col"&gt;Purpose&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="data"&gt;_CLIENTUSERID&lt;/TD&gt;
&lt;TD class="data"&gt;'S123456'&lt;/TD&gt;
&lt;TD class="data"&gt;Windows user ID in SAS EG&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="data"&gt;_CLIENTUSERNAME&lt;/TD&gt;
&lt;TD class="data"&gt;'my name'&lt;/TD&gt;
&lt;TD class="data"&gt;Windows user name in SAS EG&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="data"&gt;_METAUSER&lt;/TD&gt;
&lt;TD class="data"&gt;S123456&lt;/TD&gt;
&lt;TD class="data"&gt;SAS metadata user ID&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="data"&gt;SYSUSERID&lt;/TD&gt;
&lt;TD class="data"&gt;S123456&lt;/TD&gt;
&lt;TD class="data"&gt;SAS session host account&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the out file :&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HTTP/1.1 401 Unauthorized&lt;BR /&gt;Content-Type: text/plain; charset=utf-8&lt;BR /&gt;Server: Microsoft-IIS/8.5&lt;BR /&gt;SPRequestGuid: 6f3e11a0-f343-5019-a75a-65092f2b13f2&lt;BR /&gt;request-id: 6f3e11a0-f343-5019-a75a-65092f2b13f2&lt;BR /&gt;X-FRAME-OPTIONS: SAMEORIGIN&lt;BR /&gt;SPRequestDuration: 2&lt;BR /&gt;SPIisLatency: 0&lt;BR /&gt;WWW-Authenticate: Negotiate&lt;BR /&gt;WWW-Authenticate: NTLM&lt;BR /&gt;X-Powered-By: ASP.NET&lt;BR /&gt;MicrosoftSharePointTeamServices: 15.0.0.4885&lt;BR /&gt;X-Content-Type-Options: nosniff&lt;BR /&gt;X-MS-InvokeApp: 1; RequireReadOnly&lt;BR /&gt;Date: Tue, 28 Dec 2021 15:48:01 GMT&lt;BR /&gt;Content-Length: 16&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Dec 2021 16:06:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/401-Unauthorized-out-file-while-using-proc-HTTP-to-access-the/m-p/787527#M251645</guid>
      <dc:creator>learn_SAS_23</dc:creator>
      <dc:date>2021-12-28T16:06:04Z</dc:date>
    </item>
    <item>
      <title>Re: 401 Unauthorized out file while using proc HTTP to access the sharepoint</title>
      <link>https://communities.sas.com/t5/SAS-Programming/401-Unauthorized-out-file-while-using-proc-HTTP-to-access-the/m-p/787611#M251685</link>
      <description>&lt;P&gt;calling&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4"&gt;@ChrisHemedinger&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Dec 2021 12:52:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/401-Unauthorized-out-file-while-using-proc-HTTP-to-access-the/m-p/787611#M251685</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-12-29T12:52:17Z</dc:date>
    </item>
  </channel>
</rss>

