Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

174
Vistas
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?

about 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

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);
            },
    });
about 4 years ago · Santiago Trujillo Denunciar

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.

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda