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

125
Visualizações
HTTP API CALLS Issue when using application/x-www-form-urlencoded and header

I am trying to send a api call from my javascript with contentType: "application/x-www-form-urlencoded", But the call also requires we to include the session-token to be included in the header and when I do both of them together it gives me error. How to send both of header and content type together?

Request:

function g_ajaxerV2Receive(url_str, ok_cb, fail_cb){
    $.ajax({
        url: url_str,
        type: "POST",
        crossDomain: true,
        data: "",
        success: ok_cb,
        error: fail_cb,
        timeout: 60000,
        dataType: "json",
        contentType: "application/x-www-form-urlencoded",
        headers: {
            "Session-Token:" + String(SessionToken), //Token is in variable
        }
    });
}

The error that I get when both contentType and Header exist:

Access to XMLHttpRequest at 'https://API-URL' from origin 'http://127.0.0.1:5505' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

And the requirement for the call is that we need both The session token and the application/x-www-form-urlencoded.

The allowed CURL requestExample:

curl 'https://URL-HERE'
  -H 'Session-Token: session_token_here'
about 4 years ago · Juan Pablo Isaza
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