Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

103
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!