Curl PUT Request With JWT Authorization Header

13.4k Views Asked by At

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',
        ]
0

There are 0 best solutions below