So, i'm trying to make a request to an api, when I do it with Axios on my node project, it returns me 422, and when I do the same request, with the same header, and the same data, on postman or thunder client, they give me 200 and the data that I need. I'm having problem with this route specific.
const config = () => {
return {
headers: {
Authorization: `Bearer ${process.env.TOKEN}`,
Accept: 'application/json',
'User-Agent': `Aplicação (${process.env.CONTACT_EMAIL})`
}
}
}
router.post('/calculate', async (req, res) => {
const resp = await Axios.post(`${process.env.ENDPOINT}/api/v2/me/shipment/calculate`, req.body, config())
return res.status(200).send(resp.data);
})
req.body:
{
"from": {
"postal_code": "96020360"
},
"to": {
"postal_code": "01018020"
},
"products": [
{
"id": "x",
"width": 11,
"height": 17,
"length": 11,
"weight": 0.3,
"insurance_value": 10.1,
"quantity": 1
},
{
"id": "y",
"width": 16,
"height": 25,
"length": 11,
"weight": 0.3,
"insurance_value": 55.05,
"quantity": 2
},
{
"id": "z",
"width": 22,
"height": 30,
"length": 11,
"weight": 1,
"insurance_value": 30,
"quantity": 1
}
]
}