Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass xml while requesting Rest web service

Tags:

java

android

I want to pass xml to rest web service with request. I am unable to get how I can do this.

thanks in advance.

like image 608
user962629 Avatar asked Dec 31 '25 08:12

user962629


1 Answers

If you need a code sample:

String response = null;

    httppost = new HttpPost(URL_STRING);
    httppost.setParams(httpParams);

    String s = your_XML_Data_As_String_Or_JSON_Or_Whatever;

    try {

        StringEntity entity = new StringEntity(s);
        httppost.setEntity(entity);
        httppost.addHeader("Content-Type", "SomeMIMEType");

        response = httpclient.execute(httppost, handler);
        } catch (Exception e){
            e.printStackTrace }
like image 100
87element Avatar answered Jan 01 '26 20:01

87element



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!