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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:06:32+00:00 2026-06-15T16:06:32+00:00

I am making a call to Twitter search and getting JSON response. My understanding

  • 0

I am making a call to Twitter search and getting JSON response. My understanding is that if the twitter request limit is exceeded this will be reported in HttpResponse code. How can I obtain the response code from the HttpClient classes after the request is made?

Also does anyone know if this is in fact how twitter reports the rate limit exceeded?

    import org.apache.http.client.HttpClient;
            import org.apache.http.client.ResponseHandler;
            import org.apache.http.client.methods.HttpGet;
            import org.apache.http.impl.client.BasicResponseHandler;
            import org.apache.http.impl.client.DefaultHttpClient;

    HttpGet get = new HttpGet(searchUrl); 
    ResponseHandler<String> responseHandler = new BasicResponseHandler();
    String responseBody = null;
    try{
        responseBody = client.execute(get, responseHandler);
                    // How can I get HTTP response code?
    }
    catch(Exception ex) 
    {
        ex.printStackTrace();
    }
  • 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-06-15T16:06:33+00:00Added an answer on June 15, 2026 at 4:06 pm

    Don’t use a response handler at all – you can get the status code from a plain HttpResponse instance using HttpResponse#getStatusLine():

    HttpGet get = new HttpGet(searchUrl); 
    ResponseHandler<String> responseHandler = new BasicResponseHandler();
    HttpResponse response = client.execute(get);
    int statusCode = response.getStatusLine().getStatusCode();
    

    Recommended reading:

    • HttpResponse
    • StatusLine

    N.B. when BasicResponseHandler returns a String instead of throwing an exception, that implies the response code was a 2xx (that is, 200 <= code < 300).

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

Sidebar

Related Questions

I'm making call to Alfresco Webscripts which return JSON. I do this using GET
I m making call to server using NSURLConnection for iPhone & receiving the response
I am making ajax call like this $(document).ready(function() { var abc = new Array();
I've got an html page from where Im making this call periodically: function logon(id)
This is the code for my function, in which I am making a call
When making a function call in Linux (or OS X for that matter), can
Iam making call to our server which will checks authentication of a user and
I am making a call to a method by passing ipAddress and it will
I am making a call to: config.Save(ConfigurationSaveMode.Modified); and this call works fine in Windows
I 'm making this call: sql=select * from Lists where Name = test Cursor

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.