<?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 Re: proc http method = post xpt file in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/proc-http-method-post-xpt-file/m-p/848621#M82365</link>
    <description>&lt;P&gt;I usually start with the API documentation, which often has examples that use cURL or another language. From there it's simple to transcribe to the equivalent in SAS PROC HTTP. Is there doc for the API? I understand your data is sensitive, but is the system you're using a well-known service?&lt;/P&gt;</description>
    <pubDate>Thu, 08 Dec 2022 19:35:42 GMT</pubDate>
    <dc:creator>ChrisHemedinger</dc:creator>
    <dc:date>2022-12-08T19:35:42Z</dc:date>
    <item>
      <title>proc http method = post xpt file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-http-method-post-xpt-file/m-p/848388#M82358</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My mission(I've chosen to accept it) is to upload a zip file (bundled up XPT files in there) to an API. I'm using the code below. The issue(s) I've run into are&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) Is the code complete/correct&amp;nbsp; from the MULTI PART aspect ? The client is expecting a "multipart/form-data" type of upload.&amp;nbsp;&lt;/P&gt;&lt;P&gt;2)&amp;nbsp; Do I need the boundary to be defined, considering there are multiple xpt files in the zip file ? Currently commented out. If needed, where does it go ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Some notes:&lt;/P&gt;&lt;P&gt;1) There is no "data size" limiting this operation.&lt;/P&gt;&lt;P&gt;2) Yes, the macro variables resolve correctly. Can't share that sensitive information here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;AgNO3.&lt;/P&gt;&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4"&gt;@ChrisHemedinger&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;BR /&gt;&lt;CODE class=""&gt;options nobomfile;
filename dd_raw "../dataraw/dd_raw.zip";
/*%let boundary=%sysfunc(uuidgen());*/


proc http url = "&amp;amp;base_uri/repository/container/&amp;amp;containerAID/&amp;amp;version/assetgroup/&amp;amp;agaid/upload"
                method='post'
        in=multi (dd_raw header = "content-type: multipart/form-data", "xpt data");
        debug level=3;
        headers 'Authorization'="Bearer &amp;amp;ACCESS_TOKEN";
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="proc_http_log.PNG" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/78163iFE12B50755649EBE/image-size/large?v=v2&amp;amp;px=999" role="button" title="proc_http_log.PNG" alt="proc_http_log.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 17:34:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-http-method-post-xpt-file/m-p/848388#M82358</guid>
      <dc:creator>agno3</dc:creator>
      <dc:date>2022-12-07T17:34:38Z</dc:date>
    </item>
    <item>
      <title>Re: proc http method = post xpt file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-http-method-post-xpt-file/m-p/848445#M82360</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/88273"&gt;@agno3&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would first try without any special options, using just POST with the ZIP file as the IN= payload. If that doesn't do the trick, see the MULTI option on PROC HTTP (&lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/p10hyllh9kzzwxn1juthxahne5vp.htm" target="_self"&gt;documentation&lt;/A&gt;). Your example doesn't look like valid syntax to me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or,&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Procedures/Proc-HTTP-Box-com-REST-API-Trouble-with-uploading-binary-files/m-p/413797#M67475" target="_self"&gt;See if the example here&lt;/A&gt; helps with the task. This workaround was the trick to use before there was a MULTI option, I think.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Dec 2022 01:17:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-http-method-post-xpt-file/m-p/848445#M82360</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2022-12-08T01:17:58Z</dc:date>
    </item>
    <item>
      <title>Re: proc http method = post xpt file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-http-method-post-xpt-file/m-p/848612#M82363</link>
      <description>&lt;P&gt;Thanks for your reply.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunately, neither avenues have gotten me the intended result.&lt;/P&gt;&lt;P&gt;As for the example you pointed out to.&amp;nbsp;&amp;nbsp;the PROC ends in a "Bad Request". Below is my entire code, and the log snippet. Please see the "error:"invalid_files " message. FYI - I've tried this with 4 different files - XPT,XLSX,SAS7BDAT and a ZIP file. All of them yield the same error message. And yes, these files do have ample data in them.&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="log_snip.PNG" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/78200iBB2A87DF156F60B8/image-size/large?v=v2&amp;amp;px=999" role="button" title="log_snip.PNG" alt="log_snip.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;%let boundary=%sysfunc(uuidgen()); 
filename input1 "../dataraw/f_ae_003.xpt";

%let updestfile = f_ae_003;

data _null_;
    infile request end=eof;
    file input1;

      if _n_ = 1 then do;
        put "--&amp;amp;boundary"; 
        put 'Content-Disposition: form-data; name="attributes"';
        put ;
        put '{"name":"' "&amp;amp;updestfile" '", "parent":{"id":"' "folderID" '"}}';
        put "--&amp;amp;boundary"; 
        put 'Content-Disposition: form-data; name="file"; filename="' "&amp;amp;updestfile" '"';

        put "Content-Type: application/ASCII";
/*        put "Content-Type: application/octet-stream";*/
        put ;
      end;

    input;
    put _infile_;

    if eof then
     do;
       put "--&amp;amp;boundary--"; 
     end;
  run;

  data _null_;
    file input1 mod recfm=f lrecl=1;
    infile request  recfm=f lrecl=1;
    
    input;
    put _infile_;
run;


  *---------------------------------------------------------------------------------------;
  *&amp;gt;&amp;gt; Determine size of request and store in macro variable  *****************************;
  *---------------------------------------------------------------------------------------;
  data _null_;
    length bytes $1024;
    fid = fopen("input1");
    rc = fread(fid);
    bytes = finfo(fid, 'File Size (bytes)');
    call symput("FileSize",trim(bytes));
    rc = fclose(fid);
    put bytes;
  run;

  *---------------------------------------------------------------------------------------;
  *&amp;gt;&amp;gt; Submit the Upload request to Box  **************************************************;
  *---------------------------------------------------------------------------------------;
  proc http
      url=  "&amp;amp;base_uri/repository/container/&amp;amp;containerAID/&amp;amp;version/assetgroup/&amp;amp;agaid/upload"
        method    = "POST"
        out       = resp
        headerout = headout
        in        = input1
        ct        = "multipart/form-data; boundary=&amp;amp;boundary"
    ;
    headers
      "Authorization"  = "Bearer &amp;amp;ACCESS_TOKEN"
      "Content-Length" = "&amp;amp;filesize"
    ;
	debug level=3;

  run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;As for the SAS documentation link, something seems off (atleast to me) as word POST is not wrapped in quotes. And even when I add quotes, it doesnt "finish" running...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="documentation_example_log.PNG" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/78202i49622CA150DBCF3C/image-size/large?v=v2&amp;amp;px=999" role="button" title="documentation_example_log.PNG" alt="documentation_example_log.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Help here will be abundantly appreciated.&lt;/P&gt;&lt;P&gt;thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Dec 2022 19:09:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-http-method-post-xpt-file/m-p/848612#M82363</guid>
      <dc:creator>agno3</dc:creator>
      <dc:date>2022-12-08T19:09:51Z</dc:date>
    </item>
    <item>
      <title>Re: proc http method = post xpt file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-http-method-post-xpt-file/m-p/848621#M82365</link>
      <description>&lt;P&gt;I usually start with the API documentation, which often has examples that use cURL or another language. From there it's simple to transcribe to the equivalent in SAS PROC HTTP. Is there doc for the API? I understand your data is sensitive, but is the system you're using a well-known service?&lt;/P&gt;</description>
      <pubDate>Thu, 08 Dec 2022 19:35:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-http-method-post-xpt-file/m-p/848621#M82365</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2022-12-08T19:35:42Z</dc:date>
    </item>
  </channel>
</rss>

