<?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: How do I http post method in proc ds2? Problems with sending json question. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-http-post-method-in-proc-ds2-Problems-with-sending-json/m-p/350542#M81490</link>
    <description>&lt;P&gt;I'm not sure why there is an error in the JSON engine for this result. &amp;nbsp;I can replicate the problem here. &amp;nbsp;I know that there have been some issues fixed with the JSON engine, including one related to Byte Order Mark (BOM) which might be the cause. &amp;nbsp;The JSON response is UTF-8, I think, but the JSON engine isn't reading it properly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'll create a test case and send to the developer if I can't get it working.&lt;/P&gt;</description>
    <pubDate>Mon, 17 Apr 2017 15:21:05 GMT</pubDate>
    <dc:creator>ChrisHemedinger</dc:creator>
    <dc:date>2017-04-17T15:21:05Z</dc:date>
    <item>
      <title>How do I http post method in proc ds2? Problems with sending json question.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-http-post-method-in-proc-ds2-Problems-with-sending-json/m-p/350361#M81426</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I am trying to use a post call with http in ds2 to send a json to an rest-server.&lt;/P&gt;
&lt;P&gt;My problem is&amp;nbsp;there is no exampel how to do, all examplel using the much easier get version. I have tried to find out on my own, but can not solve the problem. I have use the process with the standard proc http and resue the settings. Something does not work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have no clue-&lt;/P&gt;
&lt;P&gt;/Anders&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is the error I got;&lt;/P&gt;
&lt;P&gt;ERROR: Error reported by DS2 package d2http:&lt;/P&gt;
&lt;P&gt;ERROR: Failed to determine encoding from content type.&lt;/P&gt;
&lt;P&gt;ERROR: Error reported by DS2 package d2http:&lt;/P&gt;
&lt;P&gt;ERROR: SETREQUESTBODYASSTRING failed for HTTP POST method with URL:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://api.scb.se/OV0104/v1/doris/sv/ssd/BE/BE0101/BE0101A/BefolkningNy" target="_blank"&gt;http://api.scb.se/OV0104/v1/doris/sv/ssd/BE/BE0101/BE0101A/BefolkningNy&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is my program.&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;ds2&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;data&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; test / &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;overwrite&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=yes;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;dcl&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;varchar&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;65000&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;) response;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;method&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;init&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;();&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;dcl&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;package&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; http scbQuery();&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;dcl&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;integer&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; rc sc;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;dcl&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;varchar&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;65000&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;) jsonQuestion;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt; jsonQuestion=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'{ &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;"query": [&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;"code": "ContentsCode",&lt;/P&gt;
&lt;P&gt;"selection": {&lt;/P&gt;
&lt;P&gt;"filter": "item",&lt;/P&gt;
&lt;P&gt;"values": [&lt;/P&gt;
&lt;P&gt;"BE0101N1"&lt;/P&gt;
&lt;P&gt;]&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;},&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;"code": "Tid",&lt;/P&gt;
&lt;P&gt;"selection": {&lt;/P&gt;
&lt;P&gt;"filter": "item",&lt;/P&gt;
&lt;P&gt;"values": [&lt;/P&gt;
&lt;P&gt;"2010",&lt;/P&gt;
&lt;P&gt;"2011"&lt;/P&gt;
&lt;P&gt;]&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;],&lt;/P&gt;
&lt;P&gt;"response": {&lt;/P&gt;
&lt;P&gt;"format": "json"&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;}'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt; scbQuery.createPostMethod(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'&lt;A href="http://api.scb.se/OV0104/v1/doris/sv/ssd/BE/BE0101/BE0101A/BefolkningNy" target="_blank"&gt;http://api.scb.se/OV0104/v1/doris/sv/ssd/BE/BE0101/BE0101A/BefolkningNy&lt;/A&gt;'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;scbQuery.setRequestBodyAsString(jsonQuestion);&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt; scbQuery.setRequestContentType(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'application/x-www-form-urlencoded; charset=ISO-8859-1'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;scbQuery.executeMethod();&lt;/P&gt;
&lt;P&gt;scbQuery.getResponseBodyAsString(response, rc);&lt;/P&gt;
&lt;P&gt;sc=scbQuery.getStatusCode();&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;put&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;'RC='&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; rc;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;put&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;'SC= '&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; sc;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;put&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;'Response= '&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; response;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;enddata&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 16 Apr 2017 14:24:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-http-post-method-in-proc-ds2-Problems-with-sending-json/m-p/350361#M81426</guid>
      <dc:creator>AndersBergquist</dc:creator>
      <dc:date>2017-04-16T14:24:51Z</dc:date>
    </item>
    <item>
      <title>Re: How do I http post method in proc ds2? Problems with sending json question.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-http-post-method-in-proc-ds2-Problems-with-sending-json/m-p/350373#M81428</link>
      <description>&lt;P&gt;Do you have to use DS2? &amp;nbsp;You might find this easier to code and debug with PROC HTTP. &lt;A href="http://blogs.sas.com/content/sasdummy/2016/07/22/slack-channel-with-sas/" target="_self"&gt;I have a POST example here&lt;/A&gt;, using PROC HTTP to publish to a Slack channel.&lt;/P&gt;</description>
      <pubDate>Sun, 16 Apr 2017 17:47:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-http-post-method-in-proc-ds2-Problems-with-sending-json/m-p/350373#M81428</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2017-04-16T17:47:27Z</dc:date>
    </item>
    <item>
      <title>Re: How do I http post method in proc ds2? Problems with sending json question.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-http-post-method-in-proc-ds2-Problems-with-sending-json/m-p/350375#M81429</link>
      <description>&lt;P&gt;I will prefere Ds2 because I need to do some loops in the final code. This because restrictions from the provider of the data. At the end, I will also use DS2 for parsing the json response.&lt;/P&gt;</description>
      <pubDate>Sun, 16 Apr 2017 18:31:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-http-post-method-in-proc-ds2-Problems-with-sending-json/m-p/350375#M81429</guid>
      <dc:creator>AndersBergquist</dc:creator>
      <dc:date>2017-04-16T18:31:14Z</dc:date>
    </item>
    <item>
      <title>Re: How do I http post method in proc ds2? Problems with sending json question.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-http-post-method-in-proc-ds2-Problems-with-sending-json/m-p/350411#M81443</link>
      <description>&lt;P&gt;Okay -- but note that you can more easily &lt;A href="http://blogs.sas.com/content/sasdummy/2016/12/02/json-libname-engine-sas/" target="_self"&gt;parse the JSON using the SAS JSON engine (SAS 9.4m4)&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Apr 2017 00:53:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-http-post-method-in-proc-ds2-Problems-with-sending-json/m-p/350411#M81443</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2017-04-17T00:53:13Z</dc:date>
    </item>
    <item>
      <title>Re: How do I http post method in proc ds2? Problems with sending json question.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-http-post-method-in-proc-ds2-Problems-with-sending-json/m-p/350428#M81454</link>
      <description>&lt;P&gt;Shall I understand You as DS2 is not worth to use? And You recomend me, and other SAS users, not to use DS2?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have use the last 3 weeks to developed an model in DS2 and got the most readable and easy to administrate code ever in SAS. I will not throuth it away-&lt;/P&gt;
&lt;P&gt;On the other side, is is easier to controll that the return from HTTP is correct is much easeier with DS2 http packet. Just chheck the status code.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Apr 2017 04:33:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-http-post-method-in-proc-ds2-Problems-with-sending-json/m-p/350428#M81454</guid>
      <dc:creator>AndersBergquist</dc:creator>
      <dc:date>2017-04-17T04:33:19Z</dc:date>
    </item>
    <item>
      <title>Re: How do I http post method in proc ds2? Problems with sending json question.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-http-post-method-in-proc-ds2-Problems-with-sending-json/m-p/350429#M81455</link>
      <description>&lt;P&gt;Here is a version with proc http and jason libname. Not so easy to sort out. The return string is direct from Statistic Sweden and work well with R.&lt;/P&gt;
&lt;P&gt;/Ansers&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Error message:&lt;/P&gt;
&lt;P&gt;ERROR: Invalid JSON in input near line 1 column 1: Encountered an illegal character.&lt;/P&gt;
&lt;P&gt;ERROR: Error in the LIBNAME statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Code:&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;filename&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; svar &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;temp&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; ;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;http&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;url&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"&lt;A href="http://api.scb.se/OV0104/v1/doris/sv/ssd/BE/BE0101/BE0101A/BefolkningNy" target="_blank"&gt;http://api.scb.se/OV0104/v1/doris/sv/ssd/BE/BE0101/BE0101A/BefolkningNy&lt;/A&gt;"&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;method&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"POST"&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;in&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'{ &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;"query": [&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;"code": "ContentsCode",&lt;/P&gt;
&lt;P&gt;"selection": {&lt;/P&gt;
&lt;P&gt;"filter": "item",&lt;/P&gt;
&lt;P&gt;"values": [&lt;/P&gt;
&lt;P&gt;"BE0101N1"&lt;/P&gt;
&lt;P&gt;]&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;},&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;"code": "Tid",&lt;/P&gt;
&lt;P&gt;"selection": {&lt;/P&gt;
&lt;P&gt;"filter": "item",&lt;/P&gt;
&lt;P&gt;"values": [&lt;/P&gt;
&lt;P&gt;"2010",&lt;/P&gt;
&lt;P&gt;"2011"&lt;/P&gt;
&lt;P&gt;]&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;],&lt;/P&gt;
&lt;P&gt;"response": {&lt;/P&gt;
&lt;P&gt;"format": "json"&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;}'&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;out&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=svar&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;ct&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"application/json;charset=Windows-1252"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;libname&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; svar json fileref=svar;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;print&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;data&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=svar;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Apr 2017 04:28:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-http-post-method-in-proc-ds2-Problems-with-sending-json/m-p/350429#M81455</guid>
      <dc:creator>AndersBergquist</dc:creator>
      <dc:date>2017-04-17T04:28:42Z</dc:date>
    </item>
    <item>
      <title>Re: How do I http post method in proc ds2? Problems with sending json question.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-http-post-method-in-proc-ds2-Problems-with-sending-json/m-p/350490#M81474</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15378"&gt;@AndersBergquist&lt;/a&gt;&amp;nbsp;- no, I'm not recommending against DS2! It's a powerful language that allows for more functional control and integration with other processes like databases. &amp;nbsp;I was just pointing out that while the JSON parsing package and the HTTP package are present in DS2, there are now some more elegant methods in "traditional" SAS programming. &amp;nbsp;To the extent that you can mix/match these techniques in your program, it might be something to explore.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Apr 2017 13:15:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-http-post-method-in-proc-ds2-Problems-with-sending-json/m-p/350490#M81474</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2017-04-17T13:15:14Z</dc:date>
    </item>
    <item>
      <title>Re: How do I http post method in proc ds2? Problems with sending json question.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-http-post-method-in-proc-ds2-Problems-with-sending-json/m-p/350538#M81488</link>
      <description>&lt;P&gt;Because I think the DS2 http packets can not been use for POST, and json libname can not work with json from statistic sweden, I think the best solution would be to us proc http for the http POST and test the DS2 json for the parsing. But I think it is not posibly to mix.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The ideal solution for me, and I think lots of SAS users in Europe there the PX-wwb api is common, is a reusable&amp;nbsp;package which can send and parse the to the different statistic authorities. Today, I have to make this manual several times each week. Maybe the http packages will work with POST in the future.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/Anders&lt;/P&gt;</description>
      <pubDate>Mon, 17 Apr 2017 15:14:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-http-post-method-in-proc-ds2-Problems-with-sending-json/m-p/350538#M81488</guid>
      <dc:creator>AndersBergquist</dc:creator>
      <dc:date>2017-04-17T15:14:54Z</dc:date>
    </item>
    <item>
      <title>Re: How do I http post method in proc ds2? Problems with sending json question.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-http-post-method-in-proc-ds2-Problems-with-sending-json/m-p/350542#M81490</link>
      <description>&lt;P&gt;I'm not sure why there is an error in the JSON engine for this result. &amp;nbsp;I can replicate the problem here. &amp;nbsp;I know that there have been some issues fixed with the JSON engine, including one related to Byte Order Mark (BOM) which might be the cause. &amp;nbsp;The JSON response is UTF-8, I think, but the JSON engine isn't reading it properly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'll create a test case and send to the developer if I can't get it working.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Apr 2017 15:21:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-http-post-method-in-proc-ds2-Problems-with-sending-json/m-p/350542#M81490</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2017-04-17T15:21:05Z</dc:date>
    </item>
    <item>
      <title>Re: How do I http post method in proc ds2? Problems with sending json question.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-http-post-method-in-proc-ds2-Problems-with-sending-json/m-p/350544#M81491</link>
      <description>&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Apr 2017 15:25:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-http-post-method-in-proc-ds2-Problems-with-sending-json/m-p/350544#M81491</guid>
      <dc:creator>AndersBergquist</dc:creator>
      <dc:date>2017-04-17T15:25:11Z</dc:date>
    </item>
    <item>
      <title>Re: How do I http post method in proc ds2? Problems with sending json question.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-http-post-method-in-proc-ds2-Problems-with-sending-json/m-p/354687#M83003</link>
      <description>&lt;P&gt;Do you got any news? I recognice package HTTP och json works with variabels which limit the data I can download from Statistic Sweden. I may have to use proc HTTP and proc json for lager datasets.&lt;/P&gt;</description>
      <pubDate>Sat, 29 Apr 2017 08:14:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-http-post-method-in-proc-ds2-Problems-with-sending-json/m-p/354687#M83003</guid>
      <dc:creator>AndersBergquist</dc:creator>
      <dc:date>2017-04-29T08:14:50Z</dc:date>
    </item>
    <item>
      <title>Re: How do I http post method in proc ds2? Problems with sending json question.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-http-post-method-in-proc-ds2-Problems-with-sending-json/m-p/675408#M203504</link>
      <description>&lt;P&gt;Here is a quick example:&lt;/P&gt;
&lt;PRE&gt;/* HTTP POST in DS2 */
proc ds2;
data _null_;
  method init();
    declare package http h();
    declare varchar(1024) headers body;
    declare int rc status;
h.createPostMethod('https://xxxxxxxxxxx');

h.setRequestContentType('application/json; charset=utf-8');
h.addRequestHeader('Accept', 'application/json');
h.addRequestHeader('VERSION', '2');
h.addRequestHeader('API-KEY', 'xxxxxxxxxxxxxxxxxxxxxxxxxxx');&lt;BR /&gt;
h.SetRequestBodyAsString('{"identifier": "xxxxx","password": "xxxxxxxxx}');

h.executeMethod();
status = h.getStatusCode();
	if status = 200 then do;
		h.getResponseHeadersAsString(headers, rc);
		h.getResponseBodyAsString(body, rc );
		put headers;
		put body;
	end;
	h.delete();
  end;
enddata; run;
quit;
&lt;/PRE&gt;
&lt;P&gt;Example also can be found here:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://go.documentation.sas.com/?docsetId=masag&amp;amp;docsetTarget=n1hljz5qvahutgn17p3n00l11mo5.htm&amp;amp;docsetVersion=5.4&amp;amp;locale=en"&gt;https://go.documentation.sas.com/?docsetId=masag&amp;amp;docsetTarget=n1hljz5qvahutgn17p3n00l11mo5.htm&amp;amp;docsetVersion=5.4&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 08 Aug 2020 16:38:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-http-post-method-in-proc-ds2-Problems-with-sending-json/m-p/675408#M203504</guid>
      <dc:creator>Expengu</dc:creator>
      <dc:date>2020-08-08T16:38:17Z</dc:date>
    </item>
  </channel>
</rss>

