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

251
Visualizações
Can't pass authorization with AJAX request on JS

I'm trying to send a basic AJAX request through browser console. The task demands an authorization so I've got a login and a secret key for the request. My code:

var xhr = new XMLHttpRequest();
xhr.open('POST', 'https://api.mindbox.cloud/v3/operations/sync?endpointId=hh.ru&operation=get.user', true, 'login', 'secret key');
xhr.setRequestHeader('Content-type', 'application/json; charset=utf-8');
xhr.send();
console.log('status:', xhr.status, xhr.statusText);
console.log('xhr.response:', xhr.response);

the problem is that everytime I get the 401 error and a response from server:

Authorization header is incorrect. Correct header example:\r\nAuthorization: Mindbox secretKey=\"PUT_YOUR_SECRET_KEY_HERE\

Can anyone kindly help me here? I've tried hard to find some info about authorization headers but couldn't achieve anything valuable.

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

0

You can set the header just like you did with Content-type

req.setRequestHeader('Authorization', 'Mindbox secretKey=\"PUT_YOUR_SECRET_KEY_HERE\"');
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