Kong / unirest-java

Unirest in Java: Simplified, lightweight HTTP client library.
http://kong.github.io/unirest-java/
MIT License
2.6k stars 594 forks source link

curl way - PUT #123

Closed diogo10 closed 5 years ago

diogo10 commented 8 years ago

hii guys, I didn't find one PUT sample....I am using Parse.com to get, post data but now I need update one object....the documentation say that I need use PUT do update a obejct.....like this....

curl -X PUT \
  -H "X-Parse-Application-Id: one big key\
  -H "X-Parse-REST-API-Key: one big key" \
  -H "Content-Type: application/json" \
  -d '{"score":73453}' \ <- data to update...like where
  https://api.parse.com/1/classes/GameScore/Ed1nuqPvcm

And here is my java code.....


 HttpResponse<JsonNode> postResponse = Unirest.put("https://api.parse.com/1/classes/Answer/"+id)
                    .header("X-Parse-Application-Id", one big key)
                    .header("X-Parse-REST-API-Key", one big key)
                    .field("data", "'{\"currently_place\":dsdsdsd}'")
                    .asJson();

But nothing happen....I am getting the confirmation but I am not passing the data correctly...the documentation say.....

To change the data on an object that already exists, send a PUT 
request to the object URL. Any keys you don't specify will remain 
unchanged, so you can update just a subset of the object's data. 
For example, if we wanted to change the score field of our object:
ryber commented 5 years ago

I don't think those two things are the same at all, and the curl command, I typically use that as --data foo1=bar1&foo2=bar2, not as json without a field identifier.

So either the curl command needs a field name or the Unirest one doesn't