1

I am trying to call webservice with get method which containing parameter in webservice. but i am unable to find answer on internet please any one could helpe me.my webservice given below

http://api.crmseries.com/user/ValidateUser?email=don@crmSerssies.com&password=visi

user3395433
  • 123
  • 2
  • 10

2 Answers2

1

This should work!

public void postData() {
    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost("http://api.crmseries.com/user/ValidateUser");

try {
    // Add your data
    List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
    nameValuePairs.add(new BasicNameValuePair("email", "don@crmSerssies.com"));
    nameValuePairs.add(new BasicNameValuePair("password", "visi"));
    httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

    // Execute HTTP Post Request
    HttpResponse response = httpclient.execute(httppost);

} catch (ClientProtocolException e) {
    // TODO Auto-generated catch block
} catch (IOException e) {
    // TODO Auto-generated catch block
}
}
FKSI
  • 148
  • 5
  • i think you code is for post method, i need it for get method where paraheter are passed through url, what u think? – user3395433 Aug 08 '14 at 09:33
  • Well, in that case you can just concatenate yout root url with your parameters – FKSI Aug 08 '14 at 09:37
  • `public void getData(String mEmail, String mPwd) { HttpClient httpclient = new DefaultHttpClient(); HttpGet httpgett = new HttpGet("http://api.crmseries.com/user/ValidateUser?email=" + mEmail + "&password=" + mPwd); try { // Execute HTTP Post Request HttpResponse response = httpclient.execute(httpget); } catch (ClientProtocolException e) { // TODO Auto-generated catch block } catch (IOException e) { // TODO Auto-generated catch block } }` – FKSI Aug 08 '14 at 09:41
0

This should be better :)

public void getData(String mEmail, String mPwd) {
        HttpClient httpclient = new DefaultHttpClient();
        HttpGet httpgett = new HttpGet("http://api.crmseries.com/user/ValidateUser?email=" + mEmail + "&password=" + mPwd);

    try {


        // Execute HTTP Post Request
        HttpResponse response = httpclient.execute(httpget);

    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
    } catch (IOException e) {
        // TODO Auto-generated catch block
    }
    }
FKSI
  • 148
  • 5