Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

230
Vistas
Get a server Error 415 when trying to access API using JavaScript

Running the below JavaScript to make a post request to an api but get the error:

Failed to load resource: the server responded with a status of 415 (Unsupported Media Type)

Cors anywhere error is:

Missing required request header. Must specify one of: origin,x-requested-with

I can access the api successfully when I make a get request. And with the post request in python I set the body as a dictionary and the post request is successful. So maybe with JavaScript my data variable object is incorrect as indicated by the 415 error? The api guide advises a body of a key and the values as a list of lists.

let username = 'username';
let password = 'password';
let data = { 'Locations': [['51.271111446577265','0.15509523254041507']] }

fetch('https://cors-anywhere.herokuapp.com/https://api.conn.example.com/info/v1/c-r/e/m-lc-rk?', {
  method: 'post',
  headers: {
    'Accept': 'application/json, text/plain, */*',
    "Content-Type": "text/plain",
    'Authorization': 'Basic ' + btoa(username + ":" + password)
  },
  body: JSON.stringify(data)
})
.then(response => response.json())
.then(data => console.log(data));
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda