0

I'm trying to use the header: X-HTTP-Method-Override: PATCH (as stated in the Tastypie Docs , just search for X-HTTP-Method-Override there) so that I can simulate a PATCH (Not supported in heroku) when using tastypie in heroku.

I'm trying out this curl request

curl --dump-header - -H "Content-Type: application/json" -H "X-HTTP-Method-Override: PATCH" -H "Authorization: ApiKey admin:TheApiKey" -X POST --data '{"token": "test1234"}' http://staging.myserver.com/api/v1/devices/449/

Locally it works perfectly well, but when I try it on my heroku-hosted app, I get:

HTTP/1.1 501 NOT IMPLEMENTED
Content-Type: text/html; charset=utf-8
Date: Fri, 25 Jan 2013 17:45:11 GMT
Server: gunicorn/0.15.0
Content-Length: 0
Connection: keep-alive

What could be the issue here?

wuputah
  • 11,285
  • 1
  • 43
  • 60
Goles
  • 11,599
  • 22
  • 79
  • 140

1 Answers1

1

The 501 error has nothing to do with Heroku.

I believe it to be the setup of your Resource.

There is a bit of a gotcha with TastyPie, and I would refer to the following line from the documentation:

"For PATCH to work, you must have put in your detail_allowed_methods setting."

i.e.

detail_allowed_methods = ['get', 'post', 'put', 'delete', 'patch']

Rhys Elsmore
  • 361
  • 1
  • 6
  • You're right and wrong, I mean , ['get', 'post', 'put', 'delete', 'patch'] are the default detail_allowed_methods, so it makes no difference to specify them. On the other side, I noticed that our back-end guy was using a fork of tastypie that was like 6 months behind the official one. That fixed the issue. – Goles Jan 25 '13 at 23:17