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 6056905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:25:45+00:00 2026-05-23T08:25:45+00:00

From my Android app I want to request a URL with GET parameters and

  • 0

From my Android app I want to request a URL with GET parameters and read the response.
In the request I must add a x-zip header.

The URL is something like

http://example.com/getmethod.aspx?id=111&method=Test

Can some one provide me code for that?

Two things are important: that it is a GET request and contains the x-zip header .

EDIT:

try {
    HttpClient client = new DefaultHttpClient();  
    String getURL = "http://example.com/getmethod.aspx?id=111&method=Test";
    HttpGet get = new HttpGet(getURL);
    get.setHeader("Content-Type", "application/x-zip");
    HttpResponse responseGet = client.execute(get);  
    HttpEntity resEntityGet = responseGet.getEntity();  
    if (resEntityGet != null) {  
        //do something with the response
        Log.i("GET ",EntityUtils.toString(resEntityGet));
    }
} catch (Exception e) {
    e.printStackTrace();
}

I try with this code but I get code with .net error: Object reference not set to an instance of an object...
I think but I’m not sure this if for x-zip header, is header in my code ok?

  • 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-23T08:25:46+00:00Added an answer on May 23, 2026 at 8:25 am

    Here’s a code excerpt we’re using in our app to set request headers. You’ll note we set the CONTENT_TYPE header only on a POST or PUT, but the general method of adding headers (via a request interceptor) is used for GET as well.

    /**
     * HTTP request types
     */
    public static final int POST_TYPE   = 1;
    public static final int GET_TYPE    = 2;
    public static final int PUT_TYPE    = 3;
    public static final int DELETE_TYPE = 4;
    
    /**
     * HTTP request header constants
     */
    public static final String CONTENT_TYPE         = "Content-Type";
    public static final String ACCEPT_ENCODING      = "Accept-Encoding";
    public static final String CONTENT_ENCODING     = "Content-Encoding";
    public static final String ENCODING_GZIP        = "gzip";
    public static final String MIME_FORM_ENCODED    = "application/x-www-form-urlencoded";
    public static final String MIME_TEXT_PLAIN      = "text/plain";
    
    private InputStream performRequest(final String contentType, final String url, final String user, final String pass,
        final Map<String, String> headers, final Map<String, String> params, final int requestType) 
                throws IOException {
    
        DefaultHttpClient client = HTTPClientFactory.newClient();
    
        client.getParams().setParameter(HttpProtocolParams.USER_AGENT, mUserAgent);
    
        // add user and pass to client credentials if present
        if ((user != null) && (pass != null)) {
            client.getCredentialsProvider().setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(user, pass));
        }
    
        // process headers using request interceptor
        final Map<String, String> sendHeaders = new HashMap<String, String>();
        if ((headers != null) && (headers.size() > 0)) {
            sendHeaders.putAll(headers);
        }
        if (requestType == HTTPRequestHelper.POST_TYPE || requestType == HTTPRequestHelper.PUT_TYPE ) {
            sendHeaders.put(HTTPRequestHelper.CONTENT_TYPE, contentType);
        }
        // request gzip encoding for response
        sendHeaders.put(HTTPRequestHelper.ACCEPT_ENCODING, HTTPRequestHelper.ENCODING_GZIP);
    
        if (sendHeaders.size() > 0) {
            client.addRequestInterceptor(new HttpRequestInterceptor() {
    
                public void process(final HttpRequest request, final HttpContext context) throws HttpException,
                    IOException {
                    for (String key : sendHeaders.keySet()) {
                        if (!request.containsHeader(key)) {
                            request.addHeader(key, sendHeaders.get(key));
                        }
                    }
                }
            });
        }
    
        //.... code omitted ....//
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im developing an android App I want to read the data in from Excel
I want to upload a foto from my android app to a facebook fan
In my app I need to download files from url locations. I want to
I'm trying to get from an Android Uri to a byte array. I have
So my app downloads images at the users' request from an online source. Through
I am developing an android app in which i want to send (name,email, cell
i launch the Default SMS Activity from my Android app in order to send
I'm working on an android app that has to send and receive information from
I've use Parse to give my iOS and Android App notifications. But I want
I want to use simple snmp get in android.I found the code for java

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.