Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

HTTPGet with multiple header parameters


kelley.drechsler Jun 21, 2021 06:21 PM

Hello,

I would like to use the HTTPGet function with the CIMIS Web API (CIMIS Web API - [REST Services] (ca.gov)). I need to enter multiple header parameters for the CIMIS Web API to work (app key, station ID, start date, end date, etc.). Is there a way to format the HTTPHeader (the 3rd input in the HTTPGet function) to understand a list of multiple header parameters? 

Thanks in advance,

Kelley


Sam Jul 5, 2021 06:55 PM

Try putting your parameters in the URI 

https://et.water.ca.gov/Rest/Index

Public Handle As Long
Public URI As String * 255
Public HTTPResponse As String
Public HTTPHeader As String
Const CRLF = CHR(13) & CHR(10)

BeginProg
  Scan (60,Sec,0,0)
    URI = "http://et.water.ca.gov/api/data?appKey=YOUR-APP-KEY&targets=2,8,127&startDate=2010-01-01&endDate=2010-01-05"
    HTTPResponse = ""
    HTTPHeader = "Accept: application/xml" & CRLF
   Handle = HTTPGet (URI,HTTPResponse,HTTPHeader,3000)
  NextScan

 

Or try putting the parameters in the HTTPHeader parameter

 

Public Handle As Long
Public URI As String * 255
Public HTTPResponse As String
Public HTTPHeader As String * 255
Const CRLF = CHR(13) & CHR(10)

BeginProg
  Scan (60,Sec,0,0)
    URI = "http://et.water.ca.gov/api/data"
    HTTPResponse = ""
    HTTPHeader &= "appKey: YOUR-APP-KEY" & CRLF
    HTTPHeader &= "targets: 2,8,127" & CRLF
    HTTPHeader &= "startDate: 2010-01-01" & CRLF
    HTTPHeader &= "endDate: 2010-01-05" & CRLF
    HTTPHeader &= "Accept: application/xml" & CRLF
    Handle = HTTPGet (URI,HTTPResponse,HTTPHeader,3000)
  NextScan
EndProg

 

Log in or register to post/reply in the forum.