<?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 Including Binary Content in Proc HTTP POST request in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Including-Binary-Content-in-Proc-HTTP-POST-request/m-p/877016#M346458</link>
    <description>&lt;P&gt;I'm trying to perform a rest API POST request to upload an attachment to a Share Point List&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've successfully managed it with Postman via the file link on the Body /Binary tab of PostMan&lt;/P&gt;&lt;P&gt;(with URL&amp;nbsp;&lt;SPAN&gt;&lt;A href="https://mysharepointsite/_api/Web/Lists(guid'mylistguid')/items(7406)/AttachmentFiles/" target="_blank"&gt;https://mysharepointsite/_api/Web/Lists(guid'mylistguid')/items(7406)/AttachmentFiles/&lt;/A&gt; add(FileName='myfile.xlsx')&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;but I can't work out how to code the binary data part in SAS Proc HTTP&lt;BR /&gt;&lt;BR /&gt;The curl snippet for the binary content is&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;--data-binary&amp;nbsp;'@/Y:/API_Project/SharePoint/OutPut/myfile.xlsx'&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;This is my last attempt&lt;BR /&gt;&lt;PRE&gt;proc http
url= "https://mysharepointsite/_api/Web/Lists(guid'mylistguid')/Items(7406)/AttachmentFiles/ add(FileName='myfile.xlsx')"
method = "POST"
OAUTH_BEARER= &amp;amp;token.
&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;IN= '@/Y:/API_Project/SharePoint/OutPut/myfile.xlsx'&lt;/STRONG&gt;&lt;/FONT&gt;
headerout = Atthead
HEADEROUT_OVERWRITE
clear_cache;
headers "X-RequestDigest"="&amp;amp;FDV." "Accept"="application/json";
run;&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Tue, 23 May 2023 09:17:57 GMT</pubDate>
    <dc:creator>kerrmc36</dc:creator>
    <dc:date>2023-05-23T09:17:57Z</dc:date>
    <item>
      <title>Including Binary Content in Proc HTTP POST request</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Including-Binary-Content-in-Proc-HTTP-POST-request/m-p/877016#M346458</link>
      <description>&lt;P&gt;I'm trying to perform a rest API POST request to upload an attachment to a Share Point List&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've successfully managed it with Postman via the file link on the Body /Binary tab of PostMan&lt;/P&gt;&lt;P&gt;(with URL&amp;nbsp;&lt;SPAN&gt;&lt;A href="https://mysharepointsite/_api/Web/Lists(guid'mylistguid')/items(7406)/AttachmentFiles/" target="_blank"&gt;https://mysharepointsite/_api/Web/Lists(guid'mylistguid')/items(7406)/AttachmentFiles/&lt;/A&gt; add(FileName='myfile.xlsx')&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;but I can't work out how to code the binary data part in SAS Proc HTTP&lt;BR /&gt;&lt;BR /&gt;The curl snippet for the binary content is&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;--data-binary&amp;nbsp;'@/Y:/API_Project/SharePoint/OutPut/myfile.xlsx'&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;This is my last attempt&lt;BR /&gt;&lt;PRE&gt;proc http
url= "https://mysharepointsite/_api/Web/Lists(guid'mylistguid')/Items(7406)/AttachmentFiles/ add(FileName='myfile.xlsx')"
method = "POST"
OAUTH_BEARER= &amp;amp;token.
&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;IN= '@/Y:/API_Project/SharePoint/OutPut/myfile.xlsx'&lt;/STRONG&gt;&lt;/FONT&gt;
headerout = Atthead
HEADEROUT_OVERWRITE
clear_cache;
headers "X-RequestDigest"="&amp;amp;FDV." "Accept"="application/json";
run;&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 23 May 2023 09:17:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Including-Binary-Content-in-Proc-HTTP-POST-request/m-p/877016#M346458</guid>
      <dc:creator>kerrmc36</dc:creator>
      <dc:date>2023-05-23T09:17:57Z</dc:date>
    </item>
    <item>
      <title>Re: Including Binary Content in Proc HTTP POST request</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Including-Binary-Content-in-Proc-HTTP-POST-request/m-p/877040#M346462</link>
      <description>Have you seen @ ChrisHemedinger solution in this post: &lt;A href="https://communities.sas.com/t5/SAS-Programming/How-to-make-a-PROC-HTTP-Post-request-by-passing-a-JSON-message/td-p/476946" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/How-to-make-a-PROC-HTTP-Post-request-by-passing-a-JSON-message/td-p/476946&lt;/A&gt; &lt;BR /&gt;I believe that has an example that will work for you.</description>
      <pubDate>Tue, 23 May 2023 10:20:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Including-Binary-Content-in-Proc-HTTP-POST-request/m-p/877040#M346462</guid>
      <dc:creator>JosvanderVelden</dc:creator>
      <dc:date>2023-05-23T10:20:47Z</dc:date>
    </item>
    <item>
      <title>Re: Including Binary Content in Proc HTTP POST request</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Including-Binary-Content-in-Proc-HTTP-POST-request/m-p/877048#M346466</link>
      <description>&lt;P&gt;Many thanks for quick reply - I'll try creating a JSON file to read in put I'm still unclear how I should reference the file path in the JSON.&amp;nbsp; What key should I use to reference ?&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2023 11:25:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Including-Binary-Content-in-Proc-HTTP-POST-request/m-p/877048#M346466</guid>
      <dc:creator>kerrmc36</dc:creator>
      <dc:date>2023-05-23T11:25:06Z</dc:date>
    </item>
    <item>
      <title>Re: Including Binary Content in Proc HTTP POST request</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Including-Binary-Content-in-Proc-HTTP-POST-request/m-p/877289#M346580</link>
      <description>&lt;P&gt;I have not tried methods to add attachments -- only to upload files into a SharePoint collection. I've got that code in some macros in this GitHub project:&amp;nbsp;&lt;A href="https://github.com/sascommunities/sas-microsoft-graph-api/" target="_blank"&gt;https://github.com/sascommunities/sas-microsoft-graph-api/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That method uses the Upload Session API that allows for large files. It seems like this attachment approach is different, but maybe you can glean some hints from it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 May 2023 15:11:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Including-Binary-Content-in-Proc-HTTP-POST-request/m-p/877289#M346580</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2023-05-24T15:11:22Z</dc:date>
    </item>
  </channel>
</rss>

