2

I have created a REST API using Django. I'm making a POST request with some parameters

user_id="5453ab249b0dbb3b76000009"
user_type="instrcutor"

In apiary blueprint , i'm sending these as a part of request body like:

+ Request (application/json)

    + Body        

            {
                "user_id": "5453ab249b0dbb3b76000009",
                "user_type": "instructor"
            }

But in my Django view , request.POST is coming like:

{u'{\n        "user_id": "5453ab249b0dbb3b76000009",\n        "user_type": "instructor"\n}': [u'']}

instead of

{u'user_id': [u'5453ab249b0dbb3b76000009'], u'user_type': [u'instructor']}

How can i send the post data correctly ?

EDIT

Here is the solution:

+ Request (application/x-www-form-urlencoded)

    user_id=5453ab249b0dbb3b76000009&user_type=instructor
navyad
  • 3,752
  • 7
  • 47
  • 88

1 Answers1

0

If apiary is sending json (you wrote it in body block), you should look and parse request.body instead of request.POST

coldmind
  • 5,167
  • 2
  • 22
  • 22