2

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 
5
  • You must specify that your content is 'application/json' when you send to the server Commented Oct 30, 2015 at 6:00
  • @BogdanIulianBursuc in the url ? Commented Oct 30, 2015 at 6:05
  • @BogdanIulianBursuc actually it is json , I have dit my question please check Commented Oct 30, 2015 at 6:06
  • I've checked httpie and I think in order to pass an array you need to do: subject='[1,2]' put this in quotes. Have try. Commented Oct 30, 2015 at 7:20
  • @BogdanIulianBursuc yes but not just inside quotes, in my case the rt syntax would be subject:='[1,2]' , colons ':' in front of = Commented Oct 30, 2015 at 7:25

1 Answer 1

2

As @BogdanIulianBursuc suggested in his comments Httpie use differnet syntax for submitting lists.

So the right syntax would be subject:='[1,2]'

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.