One challenge I am facing is sending an HTTP POST request that accepts the body as form-data.
grant_type: client_credentials
When using this particular API in my application, I am required to provide a client_id and client_secret parameter for this call.
Currently, my code looks like this:
const postRequest = {
url: 'https://address',
method: 'POST',
headers: {
'authorization': 'Basic xyz',
'content-type': 'application/x-www-form-urlencoded'
},
formData: {
'grant_type': 'client_credentials'
}
};
I am struggling with how to include the id and secret into this request effectively. I have attempted the following:
formData: {
'grant_type' : 'client_credentials',
'client_id' :'id',
'client_secret' : 'secret'
}
Unfortunately, this approach does not seem to work as indicated in this resource.