Estoy tratando de llamar a otro servicio desde mi aplicación Express usando axios (también intenté buscar nodos)
Entonces, cuando llamo al servicio usando curl, soapui o swagger, funciona.
curl -X PUT --header 'Content-Type: application/json' --header 'Accept: application/json' -d '"02"' 'http://example.com/api/v1/something'Sin embargo, cuando intento usar
axios.put('http://example.com/api/v1/something', '"03"') .then((response) => { res.sendStatus(200); }) .catch((error) => { console.log(error); res.sendStatus(500); });Recibo "Solicitud fallida con el código de estado 415"
Solucionado agregando Content-Type en los encabezados
axios({ method: 'PUT', url, data: JSON.stringify(req.body), headers:{'Content-Type': 'application/json; charset=utf-8'} }) .then((response) => { res.sendStatus(200); }) .catch((error) => { logger.error(error); res.status(500).send(error); });