Forums

Django-Rest: Post returns GET?

I built out an API with django-rest, tested it on a local machine, and pushed it to PA. On my local machine a view associated with a post works perfectly. The live site throws an error.

Decorator for view in question: @api_view(['POST'])

Error: u'{"detail":"Method \"GET\" not allowed."}'.

Python Request Module snippet (note POST not get):

r=requests.post(my_url, data=json.dumps(payload), headers=headers, verify=False)

Server log: "POST /api/xxx/xxx/ HTTP/1.1" 301

No errors in the server log, no errors in the django-rest API. The post to the function does work on the browsable API. Why am I receiving a GET error on a post? I've tried things in curl and receive the same error. Is there something I need to tweak on PA?

Got it.

             / ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄\    
<<<<<<:>~  <   Yay!          |   
             \_________/

by the way- for the sake of future people reading this, how did u fix this?

It was a URL issue. I required SSL connections but hadn't updated my URL string to include the "s". You can get the same thing if you don't include the trailing slash.