Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

282
Visualizações
POST getting 415 (Unsupported Media Type) while POSTMAN returns 200

Seems like a simple issue but everywhere else suggested adding "application/json" in 'headers' which I have tried.

'Accept'and 'Content-Type' are both "application/json". Also tried both json and stringfy 'Body' but keep getting 415 on Chrome extension JavaScript.

textArraySample = ["sample","sample2"];
var serverUrl = "https://webappcontentnotification.azurewebsites.net/api/ContentUpload";
const body={
    "textbatch":textArraySample,
    "userId": userId,
    "url": window.location.href
}
let result = 
fetch(serverUrl, {
    method: 'POST',
    mode: "no-cors",
    headers: {
        'Accept': "application/json",
        'Content-Type': "application/json"
    },
    body: JSON.stringify(body)
    })
.then(response => {
    console.log('response:', response);
})
.catch((error) => {
    console.log('Error:', error);
});

Update: seems like "Content-Type" is not correctly set enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Did not see this mentioned somewhere else. The root cause is that "Content-Type" cannot be set to "application/json" while using "Mode: no-cors". link here

mode: "no-cors" only allows a limited set of headers in the request:

Accept

Accept-Language

Content-Language

Content-Type with a value of application/x-www-form-urlencoded, multipart/form-data, or text/plain

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda