I am testing the Uber API on Postman and I can successfully send a request with form data. When I try to translate this request using Node.js and in the axios library, I get an error.
Here's what my Postman request looks like:

The answer I get is: { "error": "invalid_client" }
Here is what I do in Node.js and axios:
var axios = require("axios"); const config = { headers: { 'Content-Type': 'multipart/form-data' } }; axios.post('https://login.uber.com/oauth/v2/token', { client_id: '***', client_secret: '***', grant_type: 'authorization_code', redirect_uri: 'http://localhost:8080/', code: '***' }, config) .then(function(response) { console.log(response.data) }) .catch(function(error) { console.log(error) })
When I do this, I get a 400 response.
I added the header 'multipart/form-data' because I filled in the form data in a Postman request. Without a header, I get the same result.
I expect to get the same answer I get from Postman, is there something wrong with my configuration variable in the Node.js script?
Any help would be appreciated!
source share