Content-Type: application/json leads to BAD REQUEST

Issue #163 new
Anonymous created an issue

if I try to POST Json data to my application I always get a BAD REQUEST (normal key-value pairs work just fine).

My looks:

class CsrfExemptResource(Resource): """A Custom Resource that is csrf exempt""" def init(self, handler, authentication=None): super(CsrfExemptResource, self).init(handler, authentication) self.csrf_exempt = getattr(self.handler, 'csrf_exempt', True)

my_handler = CsrfExemptResource(MyHandler)

urlpatterns = patterns('', url(r'^resource$', recipe_handler) )

My Handler:

class MyHandler(AnonymousBaseHandler): def create(self, request): if request.content_type: data =
title=data['title'] return title else: return "something went wrong"

This is how I send the data to the application:

curl -i -X POST -H 'Content-Type:application /json' -X POST -d "{"content": "test", "comments": [{"content": "test1"}, {"content": "test2"}], "title": "test"}" http://localhost/api/resource

The result:

HTTP/1.1 400 BAD REQUEST Date: Wed, 27 Oct 2010 09:30:12 GMT Server: Apache/2.2.14 (Ubuntu) Vary: Authorization,Accept-Encoding Connection: close Transfer-Encoding: chunked Content-Type: text/plain

What I find confusing, the result says "Content-Type: text/plain" but I defined "Content-Type:application /json"

Comments (0)

  1. Log in to comment