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

185
Visualizações
Callrail API HTTP GET request with headers

I can throw this into a linux terminal and get results.

curl -H "Authorization: Token token={api_token}" \
 -X GET \
 "https://api.callrail.com/v2/a/{account_id}/calls.json?company_id={companyId}"

Here is what I have:

var myToken = "fakeToken1234";

$.ajax
    ({
        type: "GET",
        url: "https://api.callrail.com/v2/a/{accountId}/calls.json?company_id={companyId}",
        dataType: 'json',
        beforeSend: function (xhr) { xhr.setRequestHeader('Authorization:', + myToken ); }
    });

Per CallRail Documentation I'm supposed to pass the api_token into HTTP Authorization header. I get a 401 Unauthorized message.

I think my syntax is off but can't pin it down. Any help?

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

My problem was I didn't understand the syntax that CallRail wanted in the header.

This solved it: headers: { "Authorization": 'Token token=' + myToken },

var myToken = "token1234";
var accountId = "Id1234";
var companyId = "Id1234";     

$.ajax
    ({
        type: "GET",
        url: "https://api.callrail.com/v2/a/" + accountId + "/calls/timeseries.json?company_id=" + companyId + "",
        dataType: 'json',
        headers: { "Authorization": 'Token token=' + myToken },
            success: function (result) {
                console.log(result);
            },
    });
over 4 years ago · Santiago Trujillo Relatório

0

This is what I would try using "headers:":

let companyId = "";
let accountId = "";    
let myToken = "fakeToken1234";
    $.ajax({
          type: "GET",
          url: `https://api.callrail.com/v2/a/${accountId}/calls.json?company_id=${companyId}`,
          headers: {"Authorization": `Token token="${myToken}"`},
          dataType: 'json'
    });

Don't forget to also load the companyId and accountId in your url. I am assuming you are using the right url in this answer by the way.

Hope it works. I only did $.ajax requests with one API so far. So let me hear if it works. It should at the very least point you in the right direction.

over 4 years ago · Santiago Trujillo 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