i trying to connect my project in android studio to Asp.net API and i'm using Volley Lib to Get Json Request but he did'nt read the response and I getting this massage in Log ((( E/Volley: [352] BasicNetwork.performRequest: Unexpected response code 400 for http://10.10.4.150:61511/api/Feedback/30)))
public static final String GET_BY_ID = "http://10.10.4.150:61511/api/Feedback/30";
EditText id;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
id = (EditText) findViewById(R.id.idtxt);
}
public void click(View v) {
if (v.getId() == R.id.btnget) {
insertData (id.getText().toString()) ;
}
}
public void insertData (String value){
HashMap<String,String> param = new HashMap<String, String>();
param.put("id",value);
JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET, GET_BY_ID,null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
Log.d("Response", response.toString());
try {
JSONObject ob = response.getJSONObject("userId") ;
int name = ob.getInt("userId");
Toast.makeText(getBaseContext(),name,Toast.LENGTH_LONG).show();
} catch (JSONException e) {
e.printStackTrace();
Toast.makeText(getBaseContext(),e.getMessage(),Toast.LENGTH_LONG).show();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(getBaseContext(),error.getMessage(),Toast.LENGTH_LONG).show();
}
}) {
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
HashMap<String, String> headers = new HashMap<String, String>();
headers.put("Content-Type", "application/json; charset=utf-8");
headers.put("User-agent", "My useragent");
return headers;
}};
RequestQueue requestQueue = Volley.newRequestQueue(this);
requestQueue.add(request);
}
}
What I have tried:
i trying to connect my project in android studio to Asp.net API and i'm using Volley Lib to Get Json Request but he did'nt read the response and I getting this massage in Log ((( E/Volley: [352] BasicNetwork.performRequest: Unexpected response code 400 for http://10.10.4.150:61511/api/Feedback/30)))