Axios request not setting provided headers

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:

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

Hello @Aryan_Maloo ,

I tried with axios 1.3.4 and it works, but reading here and there I see that some people use URLSearchParams

https://axios-http.com/docs/urlencoded

This topic was automatically closed 6 days after the last reply. New replies are no longer allowed.