--Scott,
I have reached my next roadblock. The API will only return 100 records unless you tell it that you want to use asynchronous processing. In postman I have to add a line to the header that says Prefer: respond-async. This will then give a response in the header that you then use in the next call to fetch the data asynchronously.
How/where do I include the Prefer: respond-async in the header?
I though perhaps I could include it in the postdata parameter, but that does not seem work.
// tell it we want async processing and get response.........
postdata = 'Prefer:respond-async' ;
response = http_string('GET': URL: postdata: '') ;
From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx <ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx> On Behalf Of Scott Klement
Sent: Friday, April 9, 2021 10:16 AM
To: ftpapi@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [Ftpapi] Authentication type =Bearer with token
Les,
In the current beta version of httpapi (http://www.scottklement.com/httpapi/beta) you can do this:
http_setAuth(HTTP_AUTH_BEARER: '': YourToken);
In older versions you have to build the header yourself using an HTTP_POINT_ADDL_HEADER callback.
Also -- I do not understand why you are calling http_persist_open in your example. What is that meant to do?
--Scott Klementsk@xxxxxxxxxxxxxxxx
On 4/8/2021 10:28 AM, Les Turner wrote:
I have a requirement to get data from a secure API. It requires a certificate in the DCM, which I have set up. Then I have to make 2 calls.
The first one is a POST and you use basic authentication to pass a UserID and password to get back a token in the response body. This is working with this code:
// Open persistent connection
pComm = http_persist_open(URL);
// Set credentials
http_setauth(HTTP_AUTH_BASIC: username: passwd);
// use the certificate in the DCM
app_id = 'ADP_APPLICATION';
rc = https_init(app_id);
if rc = -1;
http_comp(http_error());
https_cleanup();
return;
endif;
response = http_string('POST': URL: postdata: 'application/json') ;
I am able to extract the token from the Response variable. The problem is with the second call. That token is then used in the second request which makes a GET to return the data stream. However the second request uses authentication type “Bearer” and I don’t know how to code for that with HTTPAPI.
I can make it work in Postman by pasting the token into the header authorization variable with the word Bearer. I would appreciate any help you can give on how to pass a bearer token with HTTPAPI. Thanks!
Les Turner
Developer
Information Technology
ManhattanLife Insurance
T: 713-821-6414
_______________________________________________
Ftpapi mailing list
Ftpapi@xxxxxxxxxxxxxxxxxxxxxx
http://scottklement.com/mailman/listinfo/ftpapi
-- _______________________________________________ Ftpapi mailing list Ftpapi@xxxxxxxxxxxxxxxxxxxxxx http://scottklement.com/mailman/listinfo/ftpapi