Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

229
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!