[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Ftpapi] Adding security token in HTTPAPI header

Greetings all-

I'm working on consuming a JSON web service.

This script works in cURL for Windows:

curl -k "https://XXXXX.com/api/v1/test" ^
  -H "X-Api-Token: XXXYYYZZZ" ^​
  -H "Content-Type: application/json" ^​
  -d @jsontestdata.txt ^  

The authorization phrase is this:
X-Api-Token: My_API_token

http_setAuth( HTTP_AUTH_BASIC ) needs a user ID and password so that's out (getting "This page requires a user-id & password").  I've tried appending the authorization phrase delimited by CRLF's; that gives a 400 (bad request) error. 

My current code:
 JSON_response = http_string('POST'                
                            :RESTURL           ​
                            :JSON_object           ​

Would appending the auth phrase to the fourth parameter spoof the API? 
Or is http_xproc(HTTP_POINT_ADDL_HEADER) the right solution?

I appreciate all suggestions and thank you.

Ftpapi mailing list