I am adding contacts to active campaign api but the request is not sending the post parameters.The parameters are being sent from postman but with volley its not working. I have tried sending params from the constructor also but no progress. Here is the code.
Map<String, String> params = new HashMap();
params.put("email", "[email protected]");
params.put("p[1]", "1");
//JSONObject parameters = new JSONObject(params);
RequestQueue queue = Volley.newRequestQueue(MainActivity.this);
url="https://brumano.api-us1.com/admin/api.php?api_key=key&api_action=contact_add&api_output=json";
Log.d("url",url);
JsonObjectRequest jsObjRequest = new JsonObjectRequest(Request.Method.POST,url,null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
Log.d("url",response.toString());
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
// TODO Auto-generated method stub
Log.d("url",error.toString());
error.printStackTrace();
}
}){
@Override
public byte[] getBody() {
HashMap<String, String> params2 = new HashMap<String, String>();
params2.put("email", "[email protected]");
params2.put("p[1]", "1");
return new JSONObject(params2).toString().getBytes();
}
@Override
public String getBodyContentType() {
return "application/x-www-form-urlencoded;";
}
@Override
protected Map<String, String> getParams() {
Map<String, String> params2 = new HashMap<String, String>();
params2.put("email", "[email protected]");
params2.put("p[1]", "1");
return params2;
}
}
};
queue.add(jsObjRequest);
Try this using
StringRequest