Curl PUT Request With JWT Authorization Header
Asked Answered
P

0

7

I am still getting a hang of using curl for testing API request from the terminal. I have a particular issue with formatting because the API request I am attempting requires a JWT Token to be passed with every call. The request I am attempting to pass is PUT request and my question is where to place the header for the JWT token authorization. I have tried the following format and I get a error Could not resolve host: —H curl: (6) Could not resolve host: Authorization:

curl -X PUT -H "Authorization: JWT <token here>" -d "field=value" "https://url/update_record/<id>/"

Any ideas?

The call being accessed has the following permissions

class Item_Update_APIView(UpdateAPIView):
    authentication_classes = [SessionAuthentication, BasicAuthentication, JSONWebTokenAuthentication]
    permission_classes = [IsAuthenticated]
    serializer_class = ItemSerializer

    def get_queryset(self):
        id = self.kwargs['id']
        return Item.objects.filter(id__exact=id)

serializer:

class ItemSerializer(ModelSerializer):

    class Meta:
        model = Item
            fields = [
            'id',
            'booleanField',
        ]
Pandolfi answered 22/8, 2016 at 21:38 Comment(5)
Did you try "Authorization: Bearer <Token>"?Marchetti
Just tried 'curl -X PUT -H "Authorization: Bearer <token>" -d "field=value" "url/update_record/<id>"' and got '{"detail":"Authentication credentials were not provided."}'Pandolfi
There is no a mandatory header to send the token. What requires your server? If you do not include this information is not posible to answerGreenockite
I updated the question with the API class to be accessed with permissionsPandolfi
How did have you solved this?Weatherboarding

© 2022 - 2024 — McMap. All rights reserved.