<?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: Need Help to convert shell / cURL into sas code in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Need-Help-to-convert-shell-cURL-into-sas-code/m-p/860671#M339989</link>
    <description>&lt;P&gt;cURL is usually easy to transcribe into PROC HTTP. Looking at the elements in your cURL script:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;method is POST&lt;/LI&gt;
&lt;LI&gt;URL is&amp;nbsp;&lt;A href="https://yul1.qualtrics.com/API/v3/directories/directoryId/mailinglists/mailingListId/transactioncontacts" target="_blank" rel="noopener"&gt;https://yul1.qualtrics.com/API/v3/directories/directoryId/mailinglists/mailingListId/transactioncontacts&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;ContentType is application/json&lt;/LI&gt;
&lt;LI&gt;API token is in a header name-value pair (X-API-TOKEN)&lt;/LI&gt;
&lt;LI&gt;Input data (to be sent to Qualtrics) is in the --data argument, this equates to IN= in PROC HTTP.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;filename resp temp;
proc http
 method='POST'
 url="https://yul1.qualtrics.com/API/v3/directories/directoryId/mailinglists/mailingListId/transactioncontacts"
 CT="application/json"
 in='{ "transactionMeta": { "batchId": "BT_ZZZZ45678901234", "fields": [ "string" ] }, "contacts": [ { "firstName": "string", "lastName": "string", "email": "string", "extRef": "string", "embeddedData": { "property1": "string", "property2": "string" }, "language": "string", "unsubscribed": true, "transactionData": {} } ] }'
 out=resp;
 headers "X-API-TOKEN"="your-token-value";
run;

/* Check HTTP response code */
%put &amp;amp;SYS_PROCHTTP_STATUS_CODE &amp;amp;SYS_PROCHTTP_STATUS_PHRASE;

/* print response to log */
data _null_;
 rc=jsonpp('resp','log');
run;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The IN= can also take a filename/fileref, so if your data is in an external JSON file, use that method.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The response from the API, assuming it is JSON, can be read as SAS data using the JSON engine:&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;libname data json fileref=resp;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 24 Feb 2023 14:15:30 GMT</pubDate>
    <dc:creator>ChrisHemedinger</dc:creator>
    <dc:date>2023-02-24T14:15:30Z</dc:date>
    <item>
      <title>Need Help to convert shell / cURL into sas code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-Help-to-convert-shell-cURL-into-sas-code/m-p/860669#M339987</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;Here's the shell / cURL code:&lt;/P&gt;
&lt;PRE&gt;curl --request POST \ --url https://yul1.qualtrics.com/API/v3/directories/directoryId/mailinglists/mailingListId/transactioncontacts \ 
--header 'Content-Type: application/json' \ 
--header 'X-API-TOKEN: token-value' \ 
--data '{ "transactionMeta": { "batchId": "BT_ZZZZ45678901234", "fields": [ "string" ] }, "contacts": [ { "firstName": "string", "lastName": "string", "email": "string", "extRef": "string", "embeddedData": { "property1": "string", "property2": "string" }, "language": "string", "unsubscribed": true, "transactionData": {} } ] }'&lt;/PRE&gt;
&lt;P&gt;How do we convert this script into sas code ? Could you please provide an example where we add two new contacts and another example where we will provide a json file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Feb 2023 13:59:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-Help-to-convert-shell-cURL-into-sas-code/m-p/860669#M339987</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2023-02-24T13:59:38Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help to convert shell / cURL into sas code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-Help-to-convert-shell-cURL-into-sas-code/m-p/860671#M339989</link>
      <description>&lt;P&gt;cURL is usually easy to transcribe into PROC HTTP. Looking at the elements in your cURL script:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;method is POST&lt;/LI&gt;
&lt;LI&gt;URL is&amp;nbsp;&lt;A href="https://yul1.qualtrics.com/API/v3/directories/directoryId/mailinglists/mailingListId/transactioncontacts" target="_blank" rel="noopener"&gt;https://yul1.qualtrics.com/API/v3/directories/directoryId/mailinglists/mailingListId/transactioncontacts&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;ContentType is application/json&lt;/LI&gt;
&lt;LI&gt;API token is in a header name-value pair (X-API-TOKEN)&lt;/LI&gt;
&lt;LI&gt;Input data (to be sent to Qualtrics) is in the --data argument, this equates to IN= in PROC HTTP.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;filename resp temp;
proc http
 method='POST'
 url="https://yul1.qualtrics.com/API/v3/directories/directoryId/mailinglists/mailingListId/transactioncontacts"
 CT="application/json"
 in='{ "transactionMeta": { "batchId": "BT_ZZZZ45678901234", "fields": [ "string" ] }, "contacts": [ { "firstName": "string", "lastName": "string", "email": "string", "extRef": "string", "embeddedData": { "property1": "string", "property2": "string" }, "language": "string", "unsubscribed": true, "transactionData": {} } ] }'
 out=resp;
 headers "X-API-TOKEN"="your-token-value";
run;

/* Check HTTP response code */
%put &amp;amp;SYS_PROCHTTP_STATUS_CODE &amp;amp;SYS_PROCHTTP_STATUS_PHRASE;

/* print response to log */
data _null_;
 rc=jsonpp('resp','log');
run;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The IN= can also take a filename/fileref, so if your data is in an external JSON file, use that method.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The response from the API, assuming it is JSON, can be read as SAS data using the JSON engine:&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;libname data json fileref=resp;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Feb 2023 14:15:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-Help-to-convert-shell-cURL-into-sas-code/m-p/860671#M339989</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2023-02-24T14:15:30Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help to convert shell / cURL into sas code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-Help-to-convert-shell-cURL-into-sas-code/m-p/860681#M339993</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have saw your example at the url:&lt;/P&gt;
&lt;P&gt;&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;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where you are using the following code which I think is easier to read.&lt;/P&gt;
&lt;P&gt;Does the datalines portion will look like that and with or without the apostrophe?&amp;nbsp; Do we put a carriage return line feed to separate each new contact info ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;datalines;&lt;/P&gt;
&lt;PRE class="lia-code-sample  language-sas"&gt;&lt;CODE&gt;{ "transactionMeta": { "batchId": "BT_ZZZZ45678901234", "fields": [ "string" ] }, "contacts": [ { "firstName": "string", "lastName": "string", "email": "string", "extRef": "string", "embeddedData": { "property1": "string", "property2": "string" }, "language": "string", "unsubscribed": true, "transactionData": {} } ] }&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;PRE class="language-sas"&gt;&lt;CODE&gt;/* Put the body of the JSON content in external file */
filename json_in temp;
data _null_;
file json_in;
input;
put _infile_;
datalines;
{ "name":"value" }
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Feb 2023 14:44:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-Help-to-convert-shell-cURL-into-sas-code/m-p/860681#M339993</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2023-02-24T14:44:44Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help to convert shell / cURL into sas code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-Help-to-convert-shell-cURL-into-sas-code/m-p/860692#M339995</link>
      <description>&lt;P&gt;If you use that approach (which I agree is more readable), you can put the JSON content on multiple lines, as long as the complete data remains valid JSON. Break the lines at sections like commas or braces, not in the middle of quoted values.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Feb 2023 15:15:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-Help-to-convert-shell-cURL-into-sas-code/m-p/860692#M339995</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2023-02-24T15:15:47Z</dc:date>
    </item>
  </channel>
</rss>

