blahNow I am doing an ANdroid application.In my app I have to login using a url.Just like…www.blah.com/api/login/username/password.
private void sendAccelerationData()
{
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(7);
nameValuePairs.add(new BasicNameValuePair("","test3"));
nameValuePairs.add(new BasicNameValuePair("","pass3"));
this.sendData(nameValuePairs);
}
private void sendData(ArrayList<NameValuePair> data)
{
try
{
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new
HttpPost("http://blah.com/api/login/");
httppost.setEntity(new UrlEncodedFormEntity(data));
HttpResponse response = httpclient.execute(httppost);
}
}
but I am getting 404 error.and if i write my sendData() like
HttpPost("http://eesnap.com");
and sendAccelerationData() like
nameValuePairs.add(new BasicNameValuePair("","api"));
nameValuePairs.add(new BasicNameValuePair("","login"));
nameValuePairs.add(new BasicNameValuePair("","test3"));
nameValuePairs.add(new BasicNameValuePair("","pass3"));
I am getting 200 success.
If post http://www.blah.com/api/login/username/password on brower then I am getting a result on the browser
I understand my error.In ‘Get()’ method i can write code like above but in post method I have to use name value pair.