I am trying make a call to a Web Service (asmx) with parameters but I keep getting a "Missing parameter: Lane" response. the code below is what i am using
final HttpClient Client = new DefaultHttpClient();
String jsonstring = "", step = "0";
try {
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("Lane", "1"));
params.add(new BasicNameValuePair("Name", "Test test"));
HttpPost httppostreq = new HttpPost(url);
httppostreq.setEntity(new UrlEncodedFormEntity(params));
HttpResponse httpresponse = Client.execute(httppostreq);
jsonstring = EntityUtils.toString(httpresponse.getEntity());
I am able to call the Web Serviceusing Postman when I add the parameters in the header and set the "Content Type:application/x-www-form-urlencoded" but can't make it work in Android Studio
This is the code in my webservice:
[WebMethod]
public void MyTestService(string Lane, string Name)
{
Dictionary<string, object> parameter = new Dictionary<string, object>();
parameter.Add("@lane", Lane);
parameter.Add("@name", Name);
DataSet dt = DataAccess.executeStoreProcedureDataSet("sp_GetLaneName", parameter);
string jsonReturned = JsonConvert.SerializeObject(dt, Formatting.Indented);
Context.Response.ContentType = "text/plain; charset=UTF-8";
Context.Response.Write(jsonReturned);
}