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

163
Views
POST from AngularJS to Django API to obtain JWT and returning a 405 error

i'm getting this 405 when i do a POST to get the token in the endpoint that supposed accepts POST requests.

I'm using rest_framework and rest_framework_jwt

Endpoint:

from django.conf.urls import url
from django.contrib import admin
from rest_framework_jwt.views import obtain_jwt_token
from rest_framework_jwt.views import refresh_jwt_token
from rest_framework_jwt.views import verify_jwt_token

urlpatterns = [
    url(r'^$', IndexView.as_view(), name='index'),
    url(r'^api/api-token-auth/', obtain_jwt_token),
    url(r'^api/api-token-verify/', verify_jwt_token),
    url(r'^api/api-token-refresh/', refresh_jwt_token),

]

AngularJS POST:

$scope.login = function () {

          $http.post('api/api-token-auth/',
              {
                'username': $scope.username,
                'password': $scope.password
              })
              .success(function (response) {
                $scope.logged = true;
                $scope.jwt = response.token;
                console.log(response.token);
                store.set('token', response.token);
              },function (response) {
                 $scope.logged = false;
                 console.log(response);
              });
        }

I'm getting the same error when doing the POST in Postman

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

I've found the problem, in my routes i had this for AngularJS routes:

url(r'^(?P<path>.*)/$', IndexView.as_view()),

So i changed to:

url(r'^/$', IndexView.as_view()),

And it worked

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