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

96
Vistas
Django API call from extern Website via AJAX Javascript

i am working for the first time with Django Framework. A service provider is using django i can see the data only with an active Cookie on their API Docs.

We received now an API Token to call for the data on the framework.

I am trying to call the data with the Token via AJAX but i receive everytime the same console log "401 (Unauthorized)".

$.ajax({
    type: 'POST',
    headers: {
        'X-CSRFTOKEN': "XXXXXXXXXXXXXXX",
        'Content-Type': 'application/json'
    },
    url: 'www.service-provider.url/api/...',


    success: function () {
        console.log("ok");
    },
    error: function () {
        console.log("error");
    }
});

Sorry i'm a beginner at this point and have no idea where to begin with. I've searched for solution on the inet but couldn't find anything that would work.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Okay i got it! Before the token api key there must be "Token ...".

 $.ajax({
        type: 'GET',
        url: 'https://my-url.com/api/1.0/?format=json',
        
        headers:{
              "Content-Type": 'application/json',
              "Authorization": 'Token XXXXXXXXXXXXXXXXXXXXX',
              
        },
        
        success: function(data){
            console.log(data);
        }
    
    });
about 4 years ago · Juan Pablo Isaza 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