Hi Everyone,
I am making Serverless App with SMIs. I calling a third-party API using axios.post and setting the header to
headers: {
Authorization: `Basic ${base64Encode}`,
'Content-Type': 'application/x-www-form-urlencoded'
}
But when sending the request, axios is setting 'Content-type'
to 'application/json'
.
Here is my code for calling the third-party API in server.js:
let base64Encode = buffer.Buffer.from(data.iparams.client_id + ":" + data.iparams.client_secret).toString('base64');
let accTknBody = {
grant_type: "urn:ietf:params:oauth:grant-type:jwt-bearer",
assertion: String(data.iparams.jwtToken)
}
let response = await axios.post(data.iparams.server_url + '/restapi/oauth/token', accTknBody, {
headers: {
Authorization: `Basic ${base64Encode}`,
'Content-Type': 'application/x-www-form-urlencoded'
}
});
Note: All the variables have correct values.
Any help is appreciated.
Thanks