android - Retrofit post request with JsonObjectField -


i need send post requests this:

{   "request": "appstart",   "appkey": "d7ea9ac1-8eb0-44f8-809d-bff6944db6c7",   "param" : {     "somedata" : "data"   },   "buildid": "111111111-1111-1111-1111-11111111111" } 

i write simple function register appllication:

 public interface restclient {         @headers("content-type: application/json" )         @formurlencoded         @post("/")         <t> void callmethod(                 @field("request") string method,                 @field("appkey") string key,                 @field("param") jsonobject params,         );   public void registeruser(string key, string userid) {        jsonobject params = new jsonobject().putproperty("userid" userid);        api.callmethod("registeruser", key, params);  } 

this retrofit log:

request=registeruser&appkey=123bff6944db6c7&param=%7b%22deviceudid%22%3a%2276839a55470a2cd4%22%7d

how fix code?

in registeruser method build object reflects desired json structure , use retrofit's @body annotation.

public void registeruser(string key, string userid) {     callmethodbody callmethodbody = ...     api.callmethod(callmethodbody); }  public interface restclient {      @headers("content-type: application/json" )     @formurlencoded     @post("/")     <t> void callmethod(@body callmethodbody callmethodbody); } 

that send whole json string body of post request.


Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -