java - Process Post response in Play Framework -



java - Process Post response in Play Framework -

i'm @ loss how process results post in play framework. next code works process response:

wsrequestholder request = ws.url(myurl); homecoming async( request.get().map( new function<ws.response, result>() { public result apply(ws.response response) { string json = response.getbody(); system.out.println("json response: " + json); //do stuff homecoming ok(json); } } ) );

i thought i'd able replace .get() post(myvalue). however, not work. proper way process post response in play framework?

wsrequestholder.post(...) accepts 4 different types parameter: java.io.file, java.io.inputstream, jsonnode , string. can replace .get() .post(myvalue), depending on myvalue , content-type myurl expecting.

posting types set content-type header appropriate type. passing jsonnode automatically set content-type application/json, example. however, when passing string have set content-type yourself, play isn't going know whether string supposed json or form.

from play documentation:

if you're sending form:

request.setcontenttype("application/x-www-form-urlencoded").post("key1=value1&key2=value2") ...

or posting json string:

request.setcontenttype("application/json").post(jsonstring) ...

if you're having other compile errors, please post them.

java playframework playframework-2.0

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -