Adding custom header with volley request and response is “data”: “This field is required”












-1















i am just started with volley request with custom request here is peace of code what i am using for sending a custom header. headers must be
headers.put("Accept", "application/json");
headers.put("Content-Type", "application/json");



When i am hitting this url with postman it is working fine.



row data in postman
row data in postman Image



and
Headers
Headers Image



StringRequest stringRequest = new StringRequest(Request.Method.POST,
WebConstants.BASE_URL + method,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {

if (dialog != null)
dialog.dismiss();

if (response != null) {
dialog.dismiss();
Log.e("res", response);
// eventHandler.onResponse("" + method, response);
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
if (dialog != null)
dialog.dismiss();
eventHandler.onResponse("" + method, "");
}
}) {

@Override
public Map<String, String> getHeaders() throws AuthFailureError {
HashMap headers = new HashMap();
headers.put("Accept", "application/json");
headers.put("Content-Type", "application/json");

return headers != null ? headers : super.getHeaders();
}

@Override
public byte getBody() {
String str = "{"firstname":"Test", "lastname":"User", "gender":"male", "country":"US", "zipcode":"H1A NFG", "email":"testuseef434532r@mail.com", "password":"123456", "referral_code":"", "requested_plan":""}";
return str.getBytes();

}

/* Tried with this
@Override
public byte getBody() {
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("firstname","Sandeep");
jsonObject.put("lastname","Parish");
jsonObject.put("gender","M");
jsonObject.put("country","US");
jsonObject.put("zipcode","H1A NFG");
jsonObject.put("email","usermail@localmail.com");
jsonObject.put("password","123456");
jsonObject.put("referral_code","123456");
jsonObject.put("requested_plan","123456");
} catch (JSONException e) {
e.printStackTrace();
}


return jsonObject.toString().getBytes();

}

//Tried with map
@Override
protected Map<String, String> getParams() {
Map<String, String> map = new HashMap<>();
map.put("firstname", "sandeep");
map.put("lastname", "sada");
map.put("gender", "d");
map.put("country", "sdfasiio");
map.put("zipcode", "test");
map.put("email", "testmail@mail.com");
map.put("password", "0");
map.put("referral_code", "0");
map.put("requested_plan", "0");

Log.e("Map", map.toString());
return map;
}
*/

@Override
public String getBodyContentType() {
return "application/json";
}

};


stringRequest.setShouldCache(false);
stringRequest.setRetryPolicy(new DefaultRetryPolicy(
DefaultRetryPolicy.DEFAULT_TIMEOUT_MS * 2,
DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));

RequestQueue requestQueue = Volley.newRequestQueue(context);
requestQueue.add(stringRequest);


please help me to find out what's the issue with this code i am getting response with this code is.



E/res: {
"success": false,
"data": "This field is required"
}


if any issue at my side please let me know.










share|improve this question

























  • how you use it with postman? Can you show the screenshot?

    – Vladyslav Matviienko
    Nov 23 '18 at 6:05











  • you should send body parameters as key value pair instead of json string

    – Vivek Mishra
    Nov 23 '18 at 6:06











  • @VladyslavMatviienko added that and Vivek let me check with your solution.

    – Sandeep Parish
    Nov 23 '18 at 6:11











  • show the body of the request. I want to check how you send the data

    – Vladyslav Matviienko
    Nov 23 '18 at 6:12











  • @VivekMishra Thanks but issue not resolved yet

    – Sandeep Parish
    Nov 23 '18 at 6:16


















-1















i am just started with volley request with custom request here is peace of code what i am using for sending a custom header. headers must be
headers.put("Accept", "application/json");
headers.put("Content-Type", "application/json");



When i am hitting this url with postman it is working fine.



row data in postman
row data in postman Image



and
Headers
Headers Image



StringRequest stringRequest = new StringRequest(Request.Method.POST,
WebConstants.BASE_URL + method,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {

if (dialog != null)
dialog.dismiss();

if (response != null) {
dialog.dismiss();
Log.e("res", response);
// eventHandler.onResponse("" + method, response);
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
if (dialog != null)
dialog.dismiss();
eventHandler.onResponse("" + method, "");
}
}) {

@Override
public Map<String, String> getHeaders() throws AuthFailureError {
HashMap headers = new HashMap();
headers.put("Accept", "application/json");
headers.put("Content-Type", "application/json");

return headers != null ? headers : super.getHeaders();
}

@Override
public byte getBody() {
String str = "{"firstname":"Test", "lastname":"User", "gender":"male", "country":"US", "zipcode":"H1A NFG", "email":"testuseef434532r@mail.com", "password":"123456", "referral_code":"", "requested_plan":""}";
return str.getBytes();

}

/* Tried with this
@Override
public byte getBody() {
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("firstname","Sandeep");
jsonObject.put("lastname","Parish");
jsonObject.put("gender","M");
jsonObject.put("country","US");
jsonObject.put("zipcode","H1A NFG");
jsonObject.put("email","usermail@localmail.com");
jsonObject.put("password","123456");
jsonObject.put("referral_code","123456");
jsonObject.put("requested_plan","123456");
} catch (JSONException e) {
e.printStackTrace();
}


return jsonObject.toString().getBytes();

}

//Tried with map
@Override
protected Map<String, String> getParams() {
Map<String, String> map = new HashMap<>();
map.put("firstname", "sandeep");
map.put("lastname", "sada");
map.put("gender", "d");
map.put("country", "sdfasiio");
map.put("zipcode", "test");
map.put("email", "testmail@mail.com");
map.put("password", "0");
map.put("referral_code", "0");
map.put("requested_plan", "0");

Log.e("Map", map.toString());
return map;
}
*/

@Override
public String getBodyContentType() {
return "application/json";
}

};


stringRequest.setShouldCache(false);
stringRequest.setRetryPolicy(new DefaultRetryPolicy(
DefaultRetryPolicy.DEFAULT_TIMEOUT_MS * 2,
DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));

RequestQueue requestQueue = Volley.newRequestQueue(context);
requestQueue.add(stringRequest);


please help me to find out what's the issue with this code i am getting response with this code is.



E/res: {
"success": false,
"data": "This field is required"
}


if any issue at my side please let me know.










share|improve this question

























  • how you use it with postman? Can you show the screenshot?

    – Vladyslav Matviienko
    Nov 23 '18 at 6:05











  • you should send body parameters as key value pair instead of json string

    – Vivek Mishra
    Nov 23 '18 at 6:06











  • @VladyslavMatviienko added that and Vivek let me check with your solution.

    – Sandeep Parish
    Nov 23 '18 at 6:11











  • show the body of the request. I want to check how you send the data

    – Vladyslav Matviienko
    Nov 23 '18 at 6:12











  • @VivekMishra Thanks but issue not resolved yet

    – Sandeep Parish
    Nov 23 '18 at 6:16
















-1












-1








-1








i am just started with volley request with custom request here is peace of code what i am using for sending a custom header. headers must be
headers.put("Accept", "application/json");
headers.put("Content-Type", "application/json");



When i am hitting this url with postman it is working fine.



row data in postman
row data in postman Image



and
Headers
Headers Image



StringRequest stringRequest = new StringRequest(Request.Method.POST,
WebConstants.BASE_URL + method,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {

if (dialog != null)
dialog.dismiss();

if (response != null) {
dialog.dismiss();
Log.e("res", response);
// eventHandler.onResponse("" + method, response);
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
if (dialog != null)
dialog.dismiss();
eventHandler.onResponse("" + method, "");
}
}) {

@Override
public Map<String, String> getHeaders() throws AuthFailureError {
HashMap headers = new HashMap();
headers.put("Accept", "application/json");
headers.put("Content-Type", "application/json");

return headers != null ? headers : super.getHeaders();
}

@Override
public byte getBody() {
String str = "{"firstname":"Test", "lastname":"User", "gender":"male", "country":"US", "zipcode":"H1A NFG", "email":"testuseef434532r@mail.com", "password":"123456", "referral_code":"", "requested_plan":""}";
return str.getBytes();

}

/* Tried with this
@Override
public byte getBody() {
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("firstname","Sandeep");
jsonObject.put("lastname","Parish");
jsonObject.put("gender","M");
jsonObject.put("country","US");
jsonObject.put("zipcode","H1A NFG");
jsonObject.put("email","usermail@localmail.com");
jsonObject.put("password","123456");
jsonObject.put("referral_code","123456");
jsonObject.put("requested_plan","123456");
} catch (JSONException e) {
e.printStackTrace();
}


return jsonObject.toString().getBytes();

}

//Tried with map
@Override
protected Map<String, String> getParams() {
Map<String, String> map = new HashMap<>();
map.put("firstname", "sandeep");
map.put("lastname", "sada");
map.put("gender", "d");
map.put("country", "sdfasiio");
map.put("zipcode", "test");
map.put("email", "testmail@mail.com");
map.put("password", "0");
map.put("referral_code", "0");
map.put("requested_plan", "0");

Log.e("Map", map.toString());
return map;
}
*/

@Override
public String getBodyContentType() {
return "application/json";
}

};


stringRequest.setShouldCache(false);
stringRequest.setRetryPolicy(new DefaultRetryPolicy(
DefaultRetryPolicy.DEFAULT_TIMEOUT_MS * 2,
DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));

RequestQueue requestQueue = Volley.newRequestQueue(context);
requestQueue.add(stringRequest);


please help me to find out what's the issue with this code i am getting response with this code is.



E/res: {
"success": false,
"data": "This field is required"
}


if any issue at my side please let me know.










share|improve this question
















i am just started with volley request with custom request here is peace of code what i am using for sending a custom header. headers must be
headers.put("Accept", "application/json");
headers.put("Content-Type", "application/json");



When i am hitting this url with postman it is working fine.



row data in postman
row data in postman Image



and
Headers
Headers Image



StringRequest stringRequest = new StringRequest(Request.Method.POST,
WebConstants.BASE_URL + method,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {

if (dialog != null)
dialog.dismiss();

if (response != null) {
dialog.dismiss();
Log.e("res", response);
// eventHandler.onResponse("" + method, response);
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
if (dialog != null)
dialog.dismiss();
eventHandler.onResponse("" + method, "");
}
}) {

@Override
public Map<String, String> getHeaders() throws AuthFailureError {
HashMap headers = new HashMap();
headers.put("Accept", "application/json");
headers.put("Content-Type", "application/json");

return headers != null ? headers : super.getHeaders();
}

@Override
public byte getBody() {
String str = "{"firstname":"Test", "lastname":"User", "gender":"male", "country":"US", "zipcode":"H1A NFG", "email":"testuseef434532r@mail.com", "password":"123456", "referral_code":"", "requested_plan":""}";
return str.getBytes();

}

/* Tried with this
@Override
public byte getBody() {
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("firstname","Sandeep");
jsonObject.put("lastname","Parish");
jsonObject.put("gender","M");
jsonObject.put("country","US");
jsonObject.put("zipcode","H1A NFG");
jsonObject.put("email","usermail@localmail.com");
jsonObject.put("password","123456");
jsonObject.put("referral_code","123456");
jsonObject.put("requested_plan","123456");
} catch (JSONException e) {
e.printStackTrace();
}


return jsonObject.toString().getBytes();

}

//Tried with map
@Override
protected Map<String, String> getParams() {
Map<String, String> map = new HashMap<>();
map.put("firstname", "sandeep");
map.put("lastname", "sada");
map.put("gender", "d");
map.put("country", "sdfasiio");
map.put("zipcode", "test");
map.put("email", "testmail@mail.com");
map.put("password", "0");
map.put("referral_code", "0");
map.put("requested_plan", "0");

Log.e("Map", map.toString());
return map;
}
*/

@Override
public String getBodyContentType() {
return "application/json";
}

};


stringRequest.setShouldCache(false);
stringRequest.setRetryPolicy(new DefaultRetryPolicy(
DefaultRetryPolicy.DEFAULT_TIMEOUT_MS * 2,
DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));

RequestQueue requestQueue = Volley.newRequestQueue(context);
requestQueue.add(stringRequest);


please help me to find out what's the issue with this code i am getting response with this code is.



E/res: {
"success": false,
"data": "This field is required"
}


if any issue at my side please let me know.







java android android-studio android-volley






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 23 '18 at 6:38







Sandeep Parish

















asked Nov 23 '18 at 6:03









Sandeep ParishSandeep Parish

1,1161114




1,1161114













  • how you use it with postman? Can you show the screenshot?

    – Vladyslav Matviienko
    Nov 23 '18 at 6:05











  • you should send body parameters as key value pair instead of json string

    – Vivek Mishra
    Nov 23 '18 at 6:06











  • @VladyslavMatviienko added that and Vivek let me check with your solution.

    – Sandeep Parish
    Nov 23 '18 at 6:11











  • show the body of the request. I want to check how you send the data

    – Vladyslav Matviienko
    Nov 23 '18 at 6:12











  • @VivekMishra Thanks but issue not resolved yet

    – Sandeep Parish
    Nov 23 '18 at 6:16





















  • how you use it with postman? Can you show the screenshot?

    – Vladyslav Matviienko
    Nov 23 '18 at 6:05











  • you should send body parameters as key value pair instead of json string

    – Vivek Mishra
    Nov 23 '18 at 6:06











  • @VladyslavMatviienko added that and Vivek let me check with your solution.

    – Sandeep Parish
    Nov 23 '18 at 6:11











  • show the body of the request. I want to check how you send the data

    – Vladyslav Matviienko
    Nov 23 '18 at 6:12











  • @VivekMishra Thanks but issue not resolved yet

    – Sandeep Parish
    Nov 23 '18 at 6:16



















how you use it with postman? Can you show the screenshot?

– Vladyslav Matviienko
Nov 23 '18 at 6:05





how you use it with postman? Can you show the screenshot?

– Vladyslav Matviienko
Nov 23 '18 at 6:05













you should send body parameters as key value pair instead of json string

– Vivek Mishra
Nov 23 '18 at 6:06





you should send body parameters as key value pair instead of json string

– Vivek Mishra
Nov 23 '18 at 6:06













@VladyslavMatviienko added that and Vivek let me check with your solution.

– Sandeep Parish
Nov 23 '18 at 6:11





@VladyslavMatviienko added that and Vivek let me check with your solution.

– Sandeep Parish
Nov 23 '18 at 6:11













show the body of the request. I want to check how you send the data

– Vladyslav Matviienko
Nov 23 '18 at 6:12





show the body of the request. I want to check how you send the data

– Vladyslav Matviienko
Nov 23 '18 at 6:12













@VivekMishra Thanks but issue not resolved yet

– Sandeep Parish
Nov 23 '18 at 6:16







@VivekMishra Thanks but issue not resolved yet

– Sandeep Parish
Nov 23 '18 at 6:16














1 Answer
1






active

oldest

votes


















0














  StringRequest stringRequest = new StringRequest(Request.Method.POST,
WebConstants.BASE_URL + method,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {

}
}) {

@Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String, String> headers = new HashMap<>();
headers.put("Accept", "application/json");
headers.put("Content-Type", "application/json; charset=utf-8");
return headers;
}
@Override
protected Map<String, String> getParams() {
Map<String, String> map = new HashMap<>();
map.put("firstname", "sandeep");
map.put("lastname", "sada");
map.put("gender", "d");
map.put("country", "sdfasiio");
map.put("zipcode", "test");
map.put("email", "testmail@mail.com");
map.put("password", "0");
map.put("referral_code", "0");
map.put("requested_plan", "0");

Log.e("Map", map.toString());
return map;
}
};
stringRequest.setShouldCache(false);
stringRequest.setRetryPolicy(new DefaultRetryPolicy(
DefaultRetryPolicy.DEFAULT_TIMEOUT_MS * 2,
DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));

RequestQueue requestQueue = Volley.newRequestQueue(context);
requestQueue.add(stringRequest);





share|improve this answer
























  • What you change in it

    – Sandeep Parish
    Nov 26 '18 at 4:51











  • by the way thanks fr answering issue is solved

    – Sandeep Parish
    Nov 26 '18 at 4:52











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53441359%2fadding-custom-header-with-volley-request-and-response-is-data-this-field-is%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














  StringRequest stringRequest = new StringRequest(Request.Method.POST,
WebConstants.BASE_URL + method,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {

}
}) {

@Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String, String> headers = new HashMap<>();
headers.put("Accept", "application/json");
headers.put("Content-Type", "application/json; charset=utf-8");
return headers;
}
@Override
protected Map<String, String> getParams() {
Map<String, String> map = new HashMap<>();
map.put("firstname", "sandeep");
map.put("lastname", "sada");
map.put("gender", "d");
map.put("country", "sdfasiio");
map.put("zipcode", "test");
map.put("email", "testmail@mail.com");
map.put("password", "0");
map.put("referral_code", "0");
map.put("requested_plan", "0");

Log.e("Map", map.toString());
return map;
}
};
stringRequest.setShouldCache(false);
stringRequest.setRetryPolicy(new DefaultRetryPolicy(
DefaultRetryPolicy.DEFAULT_TIMEOUT_MS * 2,
DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));

RequestQueue requestQueue = Volley.newRequestQueue(context);
requestQueue.add(stringRequest);





share|improve this answer
























  • What you change in it

    – Sandeep Parish
    Nov 26 '18 at 4:51











  • by the way thanks fr answering issue is solved

    – Sandeep Parish
    Nov 26 '18 at 4:52
















0














  StringRequest stringRequest = new StringRequest(Request.Method.POST,
WebConstants.BASE_URL + method,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {

}
}) {

@Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String, String> headers = new HashMap<>();
headers.put("Accept", "application/json");
headers.put("Content-Type", "application/json; charset=utf-8");
return headers;
}
@Override
protected Map<String, String> getParams() {
Map<String, String> map = new HashMap<>();
map.put("firstname", "sandeep");
map.put("lastname", "sada");
map.put("gender", "d");
map.put("country", "sdfasiio");
map.put("zipcode", "test");
map.put("email", "testmail@mail.com");
map.put("password", "0");
map.put("referral_code", "0");
map.put("requested_plan", "0");

Log.e("Map", map.toString());
return map;
}
};
stringRequest.setShouldCache(false);
stringRequest.setRetryPolicy(new DefaultRetryPolicy(
DefaultRetryPolicy.DEFAULT_TIMEOUT_MS * 2,
DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));

RequestQueue requestQueue = Volley.newRequestQueue(context);
requestQueue.add(stringRequest);





share|improve this answer
























  • What you change in it

    – Sandeep Parish
    Nov 26 '18 at 4:51











  • by the way thanks fr answering issue is solved

    – Sandeep Parish
    Nov 26 '18 at 4:52














0












0








0







  StringRequest stringRequest = new StringRequest(Request.Method.POST,
WebConstants.BASE_URL + method,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {

}
}) {

@Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String, String> headers = new HashMap<>();
headers.put("Accept", "application/json");
headers.put("Content-Type", "application/json; charset=utf-8");
return headers;
}
@Override
protected Map<String, String> getParams() {
Map<String, String> map = new HashMap<>();
map.put("firstname", "sandeep");
map.put("lastname", "sada");
map.put("gender", "d");
map.put("country", "sdfasiio");
map.put("zipcode", "test");
map.put("email", "testmail@mail.com");
map.put("password", "0");
map.put("referral_code", "0");
map.put("requested_plan", "0");

Log.e("Map", map.toString());
return map;
}
};
stringRequest.setShouldCache(false);
stringRequest.setRetryPolicy(new DefaultRetryPolicy(
DefaultRetryPolicy.DEFAULT_TIMEOUT_MS * 2,
DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));

RequestQueue requestQueue = Volley.newRequestQueue(context);
requestQueue.add(stringRequest);





share|improve this answer













  StringRequest stringRequest = new StringRequest(Request.Method.POST,
WebConstants.BASE_URL + method,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {

}
}) {

@Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String, String> headers = new HashMap<>();
headers.put("Accept", "application/json");
headers.put("Content-Type", "application/json; charset=utf-8");
return headers;
}
@Override
protected Map<String, String> getParams() {
Map<String, String> map = new HashMap<>();
map.put("firstname", "sandeep");
map.put("lastname", "sada");
map.put("gender", "d");
map.put("country", "sdfasiio");
map.put("zipcode", "test");
map.put("email", "testmail@mail.com");
map.put("password", "0");
map.put("referral_code", "0");
map.put("requested_plan", "0");

Log.e("Map", map.toString());
return map;
}
};
stringRequest.setShouldCache(false);
stringRequest.setRetryPolicy(new DefaultRetryPolicy(
DefaultRetryPolicy.DEFAULT_TIMEOUT_MS * 2,
DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));

RequestQueue requestQueue = Volley.newRequestQueue(context);
requestQueue.add(stringRequest);






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 24 '18 at 7:39









Jatin SahgalJatin Sahgal

93




93













  • What you change in it

    – Sandeep Parish
    Nov 26 '18 at 4:51











  • by the way thanks fr answering issue is solved

    – Sandeep Parish
    Nov 26 '18 at 4:52



















  • What you change in it

    – Sandeep Parish
    Nov 26 '18 at 4:51











  • by the way thanks fr answering issue is solved

    – Sandeep Parish
    Nov 26 '18 at 4:52

















What you change in it

– Sandeep Parish
Nov 26 '18 at 4:51





What you change in it

– Sandeep Parish
Nov 26 '18 at 4:51













by the way thanks fr answering issue is solved

– Sandeep Parish
Nov 26 '18 at 4:52





by the way thanks fr answering issue is solved

– Sandeep Parish
Nov 26 '18 at 4:52


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53441359%2fadding-custom-header-with-volley-request-and-response-is-data-this-field-is%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

404 Error Contact Form 7 ajax form submitting

How to know if a Active Directory user can login interactively

TypeError: fit_transform() missing 1 required positional argument: 'X'