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

165
Vistas
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 Respuestas
Responde la pregunta

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 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