Hi all,
I am less familiar with libcurl, but working with json content works quite well. But now I need to request an access token in form-data and I’m struggling with the syntax. If Ipaste the code below into Postman, it will works fine. But I am not able to put this into correct Clarion code. Does anyone have a suggestion or example?
curl --location 'https://api.mysite.com/token' \
--header 'Cookie: last_account_activity=1741340252' \
--form 'client_id="MyID"' \
--form 'client_secret="MySecret"' \
--form 'grant_type="client_credentials"
curl.addHttpHeader('Content-Type: application/form-data')
curl.addHttpHeader('Cookie: last_account_activity=1741340252')
curl.setHttpHeaders()
curl.FormAdd('client_id',BUZ:clientId)
curl.FormAdd('client_secret',BUZ:clientSecret)
curl.FormAdd('grant_type','client_credentials')
cfres = curl.FormPost(CLIP(BUZ:url)&'/token')
IF res = CURLE_OK
MESSAGE('OK')
I’ll get a reponse OK but how to get received data. Should be a json like this:
{
"token_type": "Bearer",
"expires_in": 3600,
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGQbtSVNdg7bT9PIECGA2maMBNCLz1MqiUNvNiuMQ"
}
Regards,
Henk