http post - How to pass Object like parameters with HttpPost -



http post - How to pass Object like parameters with HttpPost -

i using restfull webservice method:

@requestmapping(value = "/rest/secure/userprofile/{providerid}", method = requestmethod.post) @responsebody public list<userprofile> adduserprofile(@requestbody object[] socialaccounts, @pathvariable string providerid, httpservletrequest request, httpservletresponse response) { system.out.println("do something!!!"); }

i want pass socialaccount object.

string json = "{\"id\":\"26651480000\",\"selected\":true,\"category\":\"software\",\"perms\":[\"administer\",\"edit_profile\",\"create_content\",\"moderate_content\",\"create_ads\",\"basic_admin\"],\"provideruserid\":\"1475334273\",\"name\":\"eran\",\"useraccesstoken\":\"caabletmsjhgbanxahalaqxvn1tri5tq8gvu002ke8zb2dcahoo21u8orrhit77g3cm6cmj4zbx2mu8koeq\",\"checked\":false,\"access_token\":\"caab0000wcuq8o\"}"; closeablehttpclient httpclient = httpclients.createdefault(); uribuilder builder = new uribuilder(); builder.setscheme("http").sethost("localhost:8080/appdev") .setpath("/rest/secure/userprofile/facebook/"); uri uri = builder.build(); httppost httppost = new httppost(uri); arraylist<namevaluepair> postparameters; postparameters = new arraylist<namevaluepair>(); postparameters.add(new basicnamevaluepair("socialaccounts", json)); httppost.setentity(new urlencodedformentity(postparameters)); httppost.setheader("x-auth-token", userlogged.gettoken()); httppost.addheader("content-type", "application/json;charset=utf-8"); closeablehttpresponse response = httpclient.execute(httppost);

i it: http/1.1 400 bad request

some advice?

i cannot comment, i'll have set answer. not sure, if solve problem actually, should replace call:

closeablehttpresponse response = httpclient.execute(httpget);

with

closeablehttpresponse response = httpclient.execute(httppost);

parameters http-post apache-httpcomponents

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -