Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

164
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda