Reputation: 259
I have created an API for CURD operation in Django REST from Rest browsable API I can view/update/delete records . But when I trie dto perform update via httpie it doesn't work.
Url - > http://localhost:8000/api/user/profile/1/
Result from browser->
{
"user": 3,
"subject": [
1,
3,
4
],
"phone": "897897897",
"address": "xcgsajgchagclkk"
}
httpie reques -> http PUT http://localhost:8000/api/user/profile/1/ user=3 subject=[1,2] phone=333 address=my
Error ->
{
"subject": [
"Expected a list of items but got type \"unicode\"."
]
}
As we can see the error is in format of data sent in request but I am sending the list in subject [1,2]
. So why its giving the error.
Edit : Header of my request
HTTP/1.0 400 BAD REQUEST
Allow: GET, PUT, PATCH, DELETE, HEAD, OPTIONS
Content-Type: application/json
Date: Fri, 30 Oct 2015 05:33:58 GMT
Server: WSGIServer/0.1 Python/2.7.6
Vary: Accept, Cookie
X-Frame-Options: SAMEORIGIN
Upvotes: 2
Views: 844
Reputation: 259
As @BogdanIulianBursuc suggested in his comments Httpie use differnet syntax for submitting lists.
So the right syntax would be subject:='[1,2]'
Upvotes: 2