Get the tools you need to learn Java skills fast!
Video tutorials, eBooks, hands-on lab exercises, sample code.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Badass: Making Users Awesome
this week in the
Sending JSON and another parameter in HTTPPost
Joined: May 05, 2010
Apr 17, 2013 04:23:30
Edit: My way of sending the parameters was correct, on the browser the petition was a Get and the answer was different.
I need to do a POST call like this
I've tried the url directly on a browser and it works
but doing this on a
application behaves differently
HashMap updateObject=new HashMap(); updateObject.put("changePrice","33"); String updateUri = "http://url.com/endpoint/?token=accessToken&updates=" + URLEncoder.encode(gson.toJson(updateObject), "UTF-8"); System.out.println(updateUri); //prints http://url.com/endpoint?token=accessToken&action=%7B%22changePrice%22%3A%2233%22%7D HttpPost update = new HttpPost(encode); update.addHeader("Content-Type", "application/json; charset=utf-8"); response = httpclient.execute(update);
I've tried encoding the entire URL and I get an error about the host not being blank.
I think the error is on the updates parameter only, but no clue where and why.
I know there are lots os similar cases, but those cases only send one parameter, the JSON, here I must send the JSON and the token separately
apache httpclient 4.2.3
I agree. Here's the link:
subject: Sending JSON and another parameter in HTTPPost
Hibernate StackOverflowError: bidirectional many-to-many
cannot connect to my MySQL db using HttpClient
Help posting .wav file in http request with HttpPost
jQuery.getJSON callback not executing
A 404 Error, need help configuring web.xml
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015