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/[email protected]&password=visi

2 Answers 2

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", "[email protected]"));
    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
}
}
Sign up to request clarification or add additional context in comments.

3 Comments

i think you code is for post method, i need it for get method where paraheter are passed through url, what u think?
Well, in that case you can just concatenate yout root url with your parameters
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 } }
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
    }
    }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.