I am trying to integrate PureCloud with a customer provided API via a custom Integration/Action
First step is to request an OAuth token from their authorization API Endpoint.
I can successfully do this using Postman; However in the token request the clientId and ClientSecret are required to be passed as form data and not in header.
e.g.: (In Postman Prerequest Script)
var client_id = "--TopSecretClientId--";
var client_secret = "--TopSecretClientSecret--)";
var resource = "--YetAnotherTopSecretVariable--";
pm.sendRequest({
url: "https://TopSecretURL/oauth2/token",
method: 'POST',
header: {
'Content-Type': 'multipart/form-data',
},
body: {
mode: 'formdata',
formdata: [
{key: "client_id", value: client_id},
{key: "client_secret", value: client_secret},
{key: "resource", value: resource},
{key: "grant_type", value: "client_credentials"},
]
}
}, function(err, response) {
const jsonResponse = response.json();
pm.environment.set("access_token", jsonResponse.access_token);
});
Where I am struggling is how to convert this to my request in my Action Configuration
e.g.:
{
"requestUrlTemplate": "https://TopSecretURL/oauth2/token",
"requestType": "POST",
"headers": {
"Content-Type": "multipart/form-data"
},
"body": {
*** HOW TO SET FORM DATA HERE PLEASE ***
}
}
Thanks