Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Question

Commonmark migration
Source Link

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

    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)

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

    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 ?

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 ?

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 ?

deleted 100 characters in body
Source Link
PEHLAJ
  • 10.2k
  • 10
  • 43
  • 57

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 ?

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 ?

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 ?

Source Link
Manohar
  • 23.6k
  • 12
  • 118
  • 158

Volley Post request ,Send Json object in Json array request

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 ?

default

AltStyle によって変換されたページ (->オリジナル) /