To say in simple words i want to send this {"Id":7,"Name":"MyName"}
data To server using Volley Post Request.
It has 1 integer and 1 String and response i get is Jsonarray
I tried Following ways but none are working
as it is json array request i cannot send data in argument as 3rd argument only takes JsonArray and i have to send JsonObject so kept it as null
new JsonArrayRequest(Method,Url,JsonArray,ResponseListener,ErrorListner)
I cannot put it in
HashMap
as 1 of the value is integer, and it only accepts string
getparams() method
@Override
protected Map<String, String> getParams() throws AuthFailureError {
Map<String,String> params=new HashMap<>();
params.put("Id",7); // <====== This is Invalid
params.put("Name","MyName");
return params;
}
- I tried to send in getbody method ,still not working
getbody method
@Override
public byte[] getBody() {
String body="{\"Id\":7,\"Name\":\"MyName\"}";
return body.getBytes();
}
I can get the response using HttpUrlConnection.
Is there any other way to achieve it in volley ?