<?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 HTTP Request with Headers? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/HTTP-Request-with-Headers/m-p/67262#M34574</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm trying to do a REST request to pull some JSON data with the following code but am getting an error. The owner of the site says I need to put the key in the request header as opposed to appending it. How does one do this in JSL with HTTP Request?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Site documentation here: &lt;A href="https://jsonodds.com/documentation" target="_blank"&gt;https://jsonodds.com/documentation&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance,&lt;/P&gt;
&lt;P&gt;-Mike&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;key = "cb8abaa5-9b10-11e8-9bbb-0b704e36c1ea"; // substitute your key
url = "https://jsonodds.com/api/odds";
request = New HTTP Request(
URL( url ), // the restAPI endpoint
Method( "GET" ),
Query String( // define key pairs
[["x-api-key" =&amp;gt; key]] // JSL associative array
)
);
data = request &amp;lt;&amp;lt; Send(); // send the request to the API&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;//ERROR BELOW&lt;/P&gt;
&lt;P&gt;GET &lt;A href="https://jsonodds.com/api/odds?x-api-key=cb8abaa5-9b10-11e8-9bbb-0a704e36c1ea" target="_blank"&gt;https://jsonodds.com/api/odds?x-api-key=cb8abaa5-9b10-11e8-9bbb-0b704e36c1ea&lt;/A&gt;&lt;BR /&gt;schannel: next InitializeSecurityContext failed: Unknown error (0x80092012) - The revocation function was unable to check revocation for the certificate.&lt;BR /&gt;Empty()&lt;/P&gt;</description>
    <pubDate>Thu, 09 Aug 2018 13:16:12 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2018-08-09T13:16:12Z</dc:date>
    <item>
      <title>HTTP Request with Headers?</title>
      <link>https://community.jmp.com/t5/Discussions/HTTP-Request-with-Headers/m-p/67262#M34574</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm trying to do a REST request to pull some JSON data with the following code but am getting an error. The owner of the site says I need to put the key in the request header as opposed to appending it. How does one do this in JSL with HTTP Request?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Site documentation here: &lt;A href="https://jsonodds.com/documentation" target="_blank"&gt;https://jsonodds.com/documentation&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance,&lt;/P&gt;
&lt;P&gt;-Mike&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;key = "cb8abaa5-9b10-11e8-9bbb-0b704e36c1ea"; // substitute your key
url = "https://jsonodds.com/api/odds";
request = New HTTP Request(
URL( url ), // the restAPI endpoint
Method( "GET" ),
Query String( // define key pairs
[["x-api-key" =&amp;gt; key]] // JSL associative array
)
);
data = request &amp;lt;&amp;lt; Send(); // send the request to the API&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;//ERROR BELOW&lt;/P&gt;
&lt;P&gt;GET &lt;A href="https://jsonodds.com/api/odds?x-api-key=cb8abaa5-9b10-11e8-9bbb-0a704e36c1ea" target="_blank"&gt;https://jsonodds.com/api/odds?x-api-key=cb8abaa5-9b10-11e8-9bbb-0b704e36c1ea&lt;/A&gt;&lt;BR /&gt;schannel: next InitializeSecurityContext failed: Unknown error (0x80092012) - The revocation function was unable to check revocation for the certificate.&lt;BR /&gt;Empty()&lt;/P&gt;</description>
      <pubDate>Thu, 09 Aug 2018 13:16:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/HTTP-Request-with-Headers/m-p/67262#M34574</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-08-09T13:16:12Z</dc:date>
    </item>
    <item>
      <title>Re: HTTP Request with Headers?</title>
      <link>https://community.jmp.com/t5/Discussions/HTTP-Request-with-Headers/m-p/67263#M34575</link>
      <description>&lt;P&gt;@Anonymous,&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://community.jmp.com/t5/JMP-Add-Ins/Getting-Started-With-REST-in-JMP/ta-p/64104" target="_blank"&gt;Getting Started With REST in JMP&lt;/A&gt;. Feel free to get this addin, it is helpful.&amp;nbsp;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am actually trying something similar on my end for an internal API and I am running into issues. While there is good documentation on Post examples, I dont see many examples in either Scripting Guide or Documentation Reference around making Get requests with access tokens. If there is anything specific you find around get requests with access tokens, please share it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Here is my attempt&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Request = New HTTP Request(
																	   URL(URLDes),
																	   Method("Get"),
																	   Headers({"Authorization = Bearer " || AccessDetails["access_token"] })
																	   //Query String([["Authorization" =&amp;gt; "Bearer" ||AccessDetails["access_token"]]])
																		  )&amp;lt;&amp;lt; Send;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Aug 2018 22:18:15 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/HTTP-Request-with-Headers/m-p/67263#M34575</guid>
      <dc:creator>uday_guntupalli</dc:creator>
      <dc:date>2018-08-08T22:18:15Z</dc:date>
    </item>
    <item>
      <title>Re: HTTP Request with Headers?</title>
      <link>https://community.jmp.com/t5/Discussions/HTTP-Request-with-Headers/m-p/67268#M34578</link>
      <description>&lt;P&gt;Using Uday's solution above I was able to get things to work. This is a pretty brief piece of code and you may need to add some variables for the URL, header, etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks to Uday for his help...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;-Mike&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;request = New HTTP Request(
URL( "https://jsonodds.com/api/odds" ), // the restAPI endpoint
Method( "GET" ),
headers( {"x-api-key: //yourkeyhere// "} ) // add your custom headers
);
dt = Open( Char To Blob( request &amp;lt;&amp;lt; Send() ), "JSON" );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Aug 2018 13:17:10 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/HTTP-Request-with-Headers/m-p/67268#M34578</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-08-09T13:17:10Z</dc:date>
    </item>
  </channel>
</rss>

