Django POST URL error

后端 未结 6 1636
栀梦
栀梦 2020-12-11 14:30

I am trying to make a REST Api in Django by outputting Json. I am having problems if i make a POST request using curl in terminal. The error i get is

6条回答
  •  臣服心动
    2020-12-11 14:59

    Another scenario can raise the exact error, not related to either csrf or APPEND_SLASH solution, below an example.

     def post(self, request, *args, **kwargs):
            data= request.data
            print(data['x'])
    

    If 'x' does not exist in the payload body, the data['x'] will raise an error, this error in my case gave a false message like the above one. Hopefully, this will help other developers.

提交回复
热议问题