Working with a new RESTFul API... The API is used to retrieve a PDF document based on the "parameters" sent. All of their examples are written in cURL syntax.
I've been provided a 32-character API "key". Here is one of the "tests"
curl --request GET \
--url https://dev-staging.companyname.com/...me/packingslip \
--header 'accept: application/pdf' \
--header 'apikey: 189f976876194069ac9f72eb30c62867'
In production, the call to the API is documented like this (where QUERYSTRING contains the "&order=12345" etc.)
curl --request GET \
--url https://dev-staging.companyname.com/...ne?QUERYSTRING
--header 'accept: application/json' \
--header 'apikey: 189f976876194069ac9f72eb30c62867'
So I'm using HTTPAPI and http_url_get to basically do the same thing.
1. I base64-encoded the API key
2. Established the easiest "test" URL
3. Then: rc = http_setauth(http_auth_basic
:%trim(apiUser)
:%trim(token64));
rc = http_url_get( URL
: Stmf // output file
: HTTP_TIMEOUT
: HTTP_USERAGENT
: modtime
:'application/json');
But I'm not sure exactly where to put the "header" stuff...
1. With previous APIs I have used the HTTP_SETAUTH to provide a key.
2. Assuming I'm changing the content-type with the 6th parameter passed via HTTP_URL_GET ('application/json')
Any help would be appreciated as my knowledge in this area is limited.
I've been provided a 32-character API "key". Here is one of the "tests"
curl --request GET \
--url https://dev-staging.companyname.com/...me/packingslip \
--header 'accept: application/pdf' \
--header 'apikey: 189f976876194069ac9f72eb30c62867'
In production, the call to the API is documented like this (where QUERYSTRING contains the "&order=12345" etc.)
curl --request GET \
--url https://dev-staging.companyname.com/...ne?QUERYSTRING
--header 'accept: application/json' \
--header 'apikey: 189f976876194069ac9f72eb30c62867'
So I'm using HTTPAPI and http_url_get to basically do the same thing.
1. I base64-encoded the API key
2. Established the easiest "test" URL
3. Then: rc = http_setauth(http_auth_basic
:%trim(apiUser)
:%trim(token64));
rc = http_url_get( URL
: Stmf // output file
: HTTP_TIMEOUT
: HTTP_USERAGENT
: modtime
:'application/json');
But I'm not sure exactly where to put the "header" stuff...
1. With previous APIs I have used the HTTP_SETAUTH to provide a key.
2. Assuming I'm changing the content-type with the 6th parameter passed via HTTP_URL_GET ('application/json')
Any help would be appreciated as my knowledge in this area is limited.



Comment