I'm trying to send data from android application to asp.net web api, I have two values to send login and password, i put them in NameValuePair List and sent them. Here is my code :
DefaultHttpClient client = new DefaultHttpClient();
List<NameValuePair> nameValuePair = new ArrayList<NameValuePair>();
nameValuePair.add(new BasicNameValuePair("login", getLogin()));
nameValuePair.add(new BasicNameValuePair("password", getPassword()));
HttpPost httpPost = new HttpPost(url);
StringEntity stringEntity = new StringEntity(new GsonBuilder().create().toJson(nameValuePair));
httpPost.setEntity(stringEntity);
httpPost.setHeader("Accept", "application/json");
httpPost.setHeader("Content-type", "application/json");
httpPost.setHeader("Accept-Encoding", "gzip");
HttpResponse httpResponse = client.execute(httpPost);
How can i deserialize the json in the web api project ? Here is the function where I would like to deserialize the Json :
[AcceptVerbs("POST")]
public string login([FromBody] object data)
{
//Here I want to get the login and password values from the json.
}