Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3948778
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:24:54+00:00 2026-05-20T01:24:54+00:00

I am performing an HTTP POST of a name/value pair and then trying to

  • 0

I am performing an HTTP POST of a name/value pair and then trying to obtain the HTTP response body (and place it into the String called description).

I’m unable to find a way to access the body of the response message. What I have below is the best I’ve come up with so far but it doesn’t work. The “description” variable just ends up empty.

The end goal is to have code on the sever-side which takes the post data and returns a message body containing useful information. For now I just have a stub html in place that always returns the same thing (see html below). In other words, the app will send a DTC (Diagnostic Trouble Code, from a car) to the server and the server will look it up and send back the description text inside of the HTML body.

Source code to the method:

public String getDTCDescription (String DTC) {
    String description = "";

    String url = "http://site/test.html";
    List<NameValuePair> args = new ArrayList<NameValuePair>();

    args.add(new BasicNameValuePair("testkey","testValue")); 

    HttpResponse h;

    h = postData(url, args);

    BufferedInputStream content = null; 
    try {
        content = new BufferedInputStream(h.getEntity().getContent());
    } catch (Exception e) {
        Log.e("NetDTCInfo",e.getMessage());
    }

    if (content == null) {
        return "";
    }

    // try and loop through all the data waiting on the input stream. 
    try {
        while (content.available() > 0) {
            Log.d("NetDTCInfo","Reading a byte...");
            description = description + (char) content.read();
            Log.d("NetDTCInfo","Description is now: " + description);
        }
    } catch (IOException e) {
        Log.e("NetDTCInfo","Error while reading. " + e.getMessage());
    }


    return description;
}

Source code to the file test.html

<html>
        <body>
                <pre>
                        P0521|This is a description of DTC code P0521.
                </pre>
        </body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T01:24:55+00:00Added an answer on May 20, 2026 at 1:24 am

    It looks your stratagy to do this is complex, rahter than sending a HTML page in respose just send a string which you want to get finally at your client side. One more thing i would suggest if you have more complex data in response message then use XML response and SAX Parsing at your client end.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Something I still don't understand when performing an http-get request to the server is
When performing many inserts into a database I would usually have code like this:
Occasionally when performing a rebase using the MercurialEclipse plugin my repository gets thrown into
I'm trying to perform a POST request with node.js, but it always seems to
I have an application that is performing HTTP Requests (specifically calling the FogBugz API)
I am having some trouble performing the following operation.. http://www.google.com --> www.google.com/ https://google.com -->
I'm performing test with POST and PUT method on a REST service. Basically I
Im performing an ajax query to check the name of a car in a
I am performing asynchronous HTTP (Ajax) requests via jQuery with the basic $.ajax(). The
I would like to return the object after the post HTTP Post or Get

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.