Here am using volley for making network transaction am tying to convert the value from sqlite to json using gson library am trying to connect with wcf service but am getting unexpected reponse 400 my url will be like this localhost/service.svc/{param} in this i need pass the value here i got struck into this how to resolve this here let me post my code:
listobj=account_sf_db.toServer();
Gson gson=new Gson();
String param=gson.toJson(listobj);
RequestQueue queue = Volley.newRequestQueue(getApplicationContext());
/* final String god=listobj.toString();
JSONObject yogan=new JSONObject();
int i=0;
JSONArray jsonArray=new JSONArray();
try {
for (Model_Account modlobj:listobj){
JSONObject jobj=new JSONObject();
jobj.put("yog", modlobj.getState());
jsonArray.put(i,jobj);
}
yogan.put("yoges",jsonArray);
}
catch (JSONException e) {
e.printStackTrace();
}*/
final String gods="yoga:";
final String URL="http://ift.tt/1PS8C36"+param;
StringRequest stringRequest = new StringRequest(Request.Method.POST, URL,
new Response.Listener<String>() {
@Override
public void onResponse(String response)
{
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
String god = error.toString();
}
}){
@Override
public Map<String, String> getHeaders ()throws AuthFailureError {
Map<String, String> params = new HashMap<String, String>();
params.put("Content-Type", "application/x-www-form-urlencoded");
return params;
}
};
queue.add(stringRequest);
stringRequest.setRetryPolicy(new DefaultRetryPolicy(5000,
DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
}
Aucun commentaire:
Enregistrer un commentaire