<?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: CURL til PROC HTTP in SAS Community Nordic</title>
    <link>https://communities.sas.com/t5/SAS-Community-Nordic/CURL-til-PROC-HTTP/m-p/510262#M186</link>
    <description>Hi&lt;BR /&gt;This may help a little bit. You need content-type and the data is formdata so it also need to be on correct form. The below code gives an http 400 error and "Error parsing multipart data", with content-type=multipart.., and http 200 with content type application/json. Unsure what is correct, as I have wrong path...&lt;BR /&gt;You can experiment with this. Two links that may help is also below:&lt;BR /&gt;** Links: &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;**        &lt;A href="https://curl.haxx.se/docs/manpage.html" target="_blank"&gt;https://curl.haxx.se/docs/manpage.html&lt;/A&gt;;&lt;BR /&gt;&lt;BR /&gt;** filenames, req is the body containing the form data.. ;;&lt;BR /&gt;** resp is the returning info from the connecting URL.. ;&lt;BR /&gt;filename req temp;&lt;BR /&gt;filename resp temp;&lt;BR /&gt;&lt;BR /&gt;** Creating the request body data as pairs of form data..;;&lt;BR /&gt;data _null_;&lt;BR /&gt;file req termstr=CRLF;&lt;BR /&gt;  put "data=@F:\SASNykredit\CURL\CURLJMICTEST2.xlsx ";&lt;BR /&gt;  put "publishdate=2018-10-30 ";&lt;BR /&gt;  put "unpublish=2018-11-22 ";&lt;BR /&gt;  put "title='JMIC TEST 2018-10-30' ";&lt;BR /&gt;  put "category='Funktionsliste' ";&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;** The HTTP POST itself..;;&lt;BR /&gt;**Unclear if it is also needs a header statement for authentication. Seems not..;;&lt;BR /&gt;proc http&lt;BR /&gt;  URL="&lt;A href="https://ptsv2.com/t/kommunikationsplatform/post" target="_blank"&gt;https://ptsv2.com/t/kommunikationsplatform/post&lt;/A&gt;"&lt;BR /&gt;  method="POST"&lt;BR /&gt;   ct="application/json"&lt;BR /&gt;  /* ct="multipart/form-data" */&lt;BR /&gt;  in=req&lt;BR /&gt;  out=resp;&lt;BR /&gt;run;&lt;BR /&gt;</description>
    <pubDate>Sun, 04 Nov 2018 18:34:04 GMT</pubDate>
    <dc:creator>TorOveKilnes</dc:creator>
    <dc:date>2018-11-04T18:34:04Z</dc:date>
    <item>
      <title>CURL til PROC HTTP</title>
      <link>https://communities.sas.com/t5/SAS-Community-Nordic/CURL-til-PROC-HTTP/m-p/509556#M185</link>
      <description>&lt;P&gt;Jeg har følgende CURL kommando jeg gerne vil have lavet om til PROC HTTP - og jeg er kommet noget af vejen. Det der mangler er selve transporten af (i dette tilfælde) XLSX filen.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;CURL -X POST -F "data=@F:\SASNykredit\CURL\CURLJMICTEST2.xlsx" -F publishdate=2018-10-30 -F unpublish=2018-11-22 -F title="JMIC TEST 2018-10-30" -F category="Funktionsliste" &lt;A href="https://ptsv2.com/t/kommunikationsplatform/post" target="_blank"&gt;https://ptsv2.com/t/kommunikationsplatform/post&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Foreløbig er jeg i SAS nået til:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;filename req temp;&lt;BR /&gt;filename resp temp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;BR /&gt;file req termstr=CRLF;&lt;BR /&gt;put "-F 'data=@F:\SASNykredit\CURL\CURLJMICTEST2.xlsx' ";&lt;BR /&gt;put '-F publishdate=2018-10-30 ';&lt;BR /&gt;put '-F unpublish=2018-11-22 ';&lt;BR /&gt;put '-F title="JMIC TEST 2018-10-30" ';&lt;BR /&gt;put '-F category="Funktionsliste" ';&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc http&lt;BR /&gt; URL="&lt;A href="https://ptsv2.com/t/kommunikationsplatform/post" target="_blank"&gt;https://ptsv2.com/t/kommunikationsplatform/post&lt;/A&gt;"&lt;BR /&gt; METHOD="POST"&lt;BR /&gt; in=req&lt;BR /&gt; out=resp;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;men som nævnt så bliver XLSX filen ikke overført. Jeg har brug for at flere forskellige filformater kan overføres (pdf, xlsx, docx etc.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Er der nogen der kan hjælpe og lede mig lidt på vej?&lt;/P&gt;</description>
      <pubDate>Thu, 01 Nov 2018 15:03:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Community-Nordic/CURL-til-PROC-HTTP/m-p/509556#M185</guid>
      <dc:creator>jmic_nyk</dc:creator>
      <dc:date>2018-11-01T15:03:38Z</dc:date>
    </item>
    <item>
      <title>Re: CURL til PROC HTTP</title>
      <link>https://communities.sas.com/t5/SAS-Community-Nordic/CURL-til-PROC-HTTP/m-p/510262#M186</link>
      <description>Hi&lt;BR /&gt;This may help a little bit. You need content-type and the data is formdata so it also need to be on correct form. The below code gives an http 400 error and "Error parsing multipart data", with content-type=multipart.., and http 200 with content type application/json. Unsure what is correct, as I have wrong path...&lt;BR /&gt;You can experiment with this. Two links that may help is also below:&lt;BR /&gt;** Links: &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;**        &lt;A href="https://curl.haxx.se/docs/manpage.html" target="_blank"&gt;https://curl.haxx.se/docs/manpage.html&lt;/A&gt;;&lt;BR /&gt;&lt;BR /&gt;** filenames, req is the body containing the form data.. ;;&lt;BR /&gt;** resp is the returning info from the connecting URL.. ;&lt;BR /&gt;filename req temp;&lt;BR /&gt;filename resp temp;&lt;BR /&gt;&lt;BR /&gt;** Creating the request body data as pairs of form data..;;&lt;BR /&gt;data _null_;&lt;BR /&gt;file req termstr=CRLF;&lt;BR /&gt;  put "data=@F:\SASNykredit\CURL\CURLJMICTEST2.xlsx ";&lt;BR /&gt;  put "publishdate=2018-10-30 ";&lt;BR /&gt;  put "unpublish=2018-11-22 ";&lt;BR /&gt;  put "title='JMIC TEST 2018-10-30' ";&lt;BR /&gt;  put "category='Funktionsliste' ";&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;** The HTTP POST itself..;;&lt;BR /&gt;**Unclear if it is also needs a header statement for authentication. Seems not..;;&lt;BR /&gt;proc http&lt;BR /&gt;  URL="&lt;A href="https://ptsv2.com/t/kommunikationsplatform/post" target="_blank"&gt;https://ptsv2.com/t/kommunikationsplatform/post&lt;/A&gt;"&lt;BR /&gt;  method="POST"&lt;BR /&gt;   ct="application/json"&lt;BR /&gt;  /* ct="multipart/form-data" */&lt;BR /&gt;  in=req&lt;BR /&gt;  out=resp;&lt;BR /&gt;run;&lt;BR /&gt;</description>
      <pubDate>Sun, 04 Nov 2018 18:34:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Community-Nordic/CURL-til-PROC-HTTP/m-p/510262#M186</guid>
      <dc:creator>TorOveKilnes</dc:creator>
      <dc:date>2018-11-04T18:34:04Z</dc:date>
    </item>
    <item>
      <title>Re: CURL til PROC HTTP</title>
      <link>https://communities.sas.com/t5/SAS-Community-Nordic/CURL-til-PROC-HTTP/m-p/510701#M187</link>
      <description>Tnx, I'll try that</description>
      <pubDate>Tue, 06 Nov 2018 08:34:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Community-Nordic/CURL-til-PROC-HTTP/m-p/510701#M187</guid>
      <dc:creator>jmic_nyk</dc:creator>
      <dc:date>2018-11-06T08:34:14Z</dc:date>
    </item>
    <item>
      <title>Re: CURL til PROC HTTP</title>
      <link>https://communities.sas.com/t5/SAS-Community-Nordic/CURL-til-PROC-HTTP/m-p/510971#M188</link>
      <description>&lt;P&gt;The above suggestion is not quite what I needed - but on the other hand, I wasn't specific&amp;nbsp;enough in my description of my needs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need the XLSX file (and other filetypes) to be posted to the URL in a binary(?) format - exactly as the cURL command does.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It looks like the HTTP procedure can't handle this directly, so you need some kind of "pre-burner". A datastep?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have looked at this post:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Procedures/upload-an-excel-file-to-box-com-using-PROC-HTTP/td-p/424118" target="_blank"&gt;https://communities.sas.com/t5/SAS-Procedures/upload-an-excel-file-to-box-com-using-PROC-HTTP/td-p/424118&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But it seems that the final solution has not yet come in this post. But is this the path to follow?&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2018 08:06:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Community-Nordic/CURL-til-PROC-HTTP/m-p/510971#M188</guid>
      <dc:creator>jmic_nyk</dc:creator>
      <dc:date>2018-11-07T08:06:14Z</dc:date>
    </item>
    <item>
      <title>SOLVED: CURL til PROC HTTP</title>
      <link>https://communities.sas.com/t5/SAS-Community-Nordic/CURL-til-PROC-HTTP/m-p/512153#M190</link>
      <description>&lt;P&gt;This code works in my case. The challenge is to find out how the Content-Type and Content-Disposition statements should look like - seems like this is different between URLs and depends on the API.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I didn't get much help from CURL parameters (should be possible, but I was not able to figure out how), but going through (=debugging) a (rather complicated) VBA script I was able to find the correct syntax for the C-D and C-T for this URL/API.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Feel free to copy&amp;nbsp;&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;
&lt;P&gt;**********************************************************&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;filename req "F:\SASNykredit\CURL-HTTP\HTTP trial\Datafiler\request.txt";&lt;BR /&gt;filename resp "F:\SASNykredit\CURL_HTTP\HTTP trial\Datafiler\response.txt";&lt;BR /&gt;filename binfile "F:\SASNykredit\CURL-HTTP\HTTP trial\Datafiler\testdata.xlsx";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let _boundary=&amp;lt;a valid boundary string&amp;gt;;&lt;BR /&gt;%let _cat=Testliste;&lt;BR /&gt;%let _publdate=%sysfunc(today(), yymmddd10.);&lt;BR /&gt;%let _unpubldate=%sysfunc(intnx(MONTH,%sysfunc(today(),8.),12,S),yymmddd10.);&lt;BR /&gt;%let _binname=%scan(%sysfunc(pathname(binfile)),-1,'\');&lt;BR /&gt;%let _title=%upcase(&amp;amp;sysuserid) TEST &amp;amp;_publdate.;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;=_boundary &amp;amp;=_cat &amp;amp;=_publdate &amp;amp;=_unpubldate &amp;amp;=_title &amp;amp;=_binname;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/*** Get the RC from PROC HTTP ***/&lt;BR /&gt;%macro prochttp_check_return(_exp_code);&lt;BR /&gt;%if %symexist(SYS_PROCHTTP_STATUS_CODE) ne 1 %then &lt;BR /&gt; %do;&lt;BR /&gt; %put ERROR: Expected &amp;amp;_exp_code., but a response was not received from the HTTP Procedure;&lt;BR /&gt; %end;&lt;BR /&gt;%else &lt;BR /&gt; %do;&lt;BR /&gt; %if &amp;amp;SYS_PROCHTTP_STATUS_CODE. ne &amp;amp;_exp_code. %then &lt;BR /&gt; %do;&lt;BR /&gt; %put ERROR: Expected &amp;amp;_exp_code., but received &amp;amp;SYS_PROCHTTP_STATUS_CODE.;&lt;BR /&gt; %put &amp;amp;SYS_PROCHTTP_STATUS_PHRASE.;&lt;BR /&gt; %end;&lt;BR /&gt; %else&lt;BR /&gt; %do;&lt;BR /&gt; %put NOTE: Alt i orden, forventet returkode: &amp;amp;SYS_PROCHTTP_STATUS_CODE. &amp;amp;SYS_PROCHTTP_STATUS_PHRASE.;&lt;BR /&gt; %end;&lt;BR /&gt; %end;&lt;BR /&gt;%mend prochttp_check_return;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;/*** Set up MULTIPART-FORM data ***/&lt;BR /&gt;data _null_;&lt;BR /&gt;file req termstr=CRLF;&lt;BR /&gt;put "--&amp;amp;_boundary.";&lt;BR /&gt;put 'Content-Disposition: form-data; name="publish"';&lt;BR /&gt;put;&lt;BR /&gt;put "&amp;amp;_publdate";&lt;BR /&gt;put "--&amp;amp;_boundary.";&lt;BR /&gt;put 'Content-Disposition: form-data; name="unpublish"';&lt;BR /&gt;put;&lt;BR /&gt;put "&amp;amp;_unpubldate";&lt;BR /&gt;put "--&amp;amp;_boundary.";&lt;BR /&gt;put 'Content-Disposition: form-data; name="category"';&lt;BR /&gt;put;&lt;BR /&gt;put "&amp;amp;_cat";&lt;BR /&gt;put "--&amp;amp;_boundary.";&lt;BR /&gt;put 'Content-Disposition: form-data; name="title"';&lt;BR /&gt;put;&lt;BR /&gt;put "&amp;amp;_title";&lt;BR /&gt;put "--&amp;amp;_boundary.";&lt;BR /&gt;put 'Content-Disposition: form-data; name="uploadfile"; filename='"&amp;amp;_binname.";&lt;BR /&gt;put 'Content-Type: application/octet-stream';&lt;BR /&gt;put;&lt;BR /&gt;%_run(w);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/*** Add the binary file ***/&lt;BR /&gt;data _null_;&lt;BR /&gt;file req mod recfm=n;&lt;BR /&gt;infile binfile recfm=n;&lt;BR /&gt;input c $CHAR1.;&lt;BR /&gt;put c $CHAR1. @@;&lt;BR /&gt;%_run(w);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/*** Wrap it up ***/&lt;BR /&gt;data _null_;&lt;BR /&gt;file req mod termstr=CRLF;&lt;BR /&gt;put / "--&amp;amp;_boundary.--";&lt;BR /&gt;%_run(w);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/*** Calling HTTP ***/&lt;/P&gt;
&lt;P&gt;proc http&lt;BR /&gt; URL="&lt;A href="https://ptsv2.com/t/kommunikationsplatform/post" target="_blank"&gt;https://ptsv2.com/t/kommunikationsplatform/post&lt;/A&gt;"&lt;BR /&gt; METHOD="POST"&lt;BR /&gt; CT="multipart/form-data; boundary=&amp;amp;_boundary"&lt;BR /&gt; in=req&lt;BR /&gt; out=resp;&lt;BR /&gt; *DEBUG Level=1;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/*** RCs from PROC HTTP ***/&lt;/P&gt;
&lt;P&gt;%put &amp;amp;=sys_prochttp_status_code.;&lt;BR /&gt;%put &amp;amp;=sys_prochttp_status_phrase.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/*** Checking the expected RC ***/&lt;BR /&gt;%prochttp_check_return(200);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/*** Finishing ***/&lt;BR /&gt;filename req clear;&lt;BR /&gt;filename resp clear;&lt;BR /&gt;filename binfile clear;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Nov 2018 11:34:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Community-Nordic/CURL-til-PROC-HTTP/m-p/512153#M190</guid>
      <dc:creator>jmic_nyk</dc:creator>
      <dc:date>2018-11-12T11:34:34Z</dc:date>
    </item>
  </channel>
</rss>

