How to send responsive array from android using retrofit -


i trying call web service receives responsive array. sending hash map values using retrofit in android giving me 500 internal server error.following code: @post("/save") public void createaccount( @body map<string, string> data, callback<response> callback);

that's how can retrofit 2

interface:

@post("/save")     call<jsonelement> createaccount(@body requestbody requestbody); 

request code:

//create jsonobject key-pair values jsonobject root = new jsonobject(); root.addproperty("key1", "value1"); root.addproperty("key2", "value2"); //get string string resultjson = root.tostring(); //parse requestbody type requestbody requestbody = requestbody.create(mediatype.parse("application/json"), resultjson); //create adapter retrofit restadapter = new retrofit.builder()         .baseurl(constants.root_api_url)         .addconverterfactory(gsonconverterfactory.create())         .build(); iconstructsecureapi service = restadapter.create(iconstructsecureapi.class);  call<jsonelement> result = service.createaccount(requestbody); result.enqueue(new callback<jsonelement>() {     @override     public void onresponse(call<jsonelement> call, retrofit2.response<jsonelement> response) {         if(response.issuccessful()){             jsonelement jsonelement = response.body();             jsonobject withresponse = jsonelement.getasjsonobject();         }         else{             system.out.println(response.message());         }     }      @override     public void onfailure(call<jsonelement> call, throwable t) {      } }); 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -