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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:26:24+00:00 2026-05-24T21:26:24+00:00

For the last two hours i’ve been trying to make a POST request to

  • 0

For the last two hours i’ve been trying to make a POST request to this page http://www.halebop.se/butik/byt_behall_nummer/ and tried to send numberToPort. However i get a bunch of cookies and a 302 moved temporarily back.

All i want to do is send the POST request with the number and get the final page back. On iOS, i do this using ASIHTTPRequest which handles the redirect and cookies.

iOS code:

NSString *halebopURLString = @"http://www.halebop.se/kontantkort/byt_behall_nummer/#";
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:halebopURLString]];
[request setPostValue:halebopNumber forKey:@"numberToPort"];
[request setPostValue:@"continue" forKey:@"action"];
[request setPostValue:@"submit" forKey:@"submit"];
[request startSynchronous];

How do i do this on Android?

As an alternative, a PHP solution is acceptable.

Edit: Tried this, it gives no output and no exceptions. I have the internet permission. Expected result: Send POST, get 302 and cookies back, send cookies to URL from 302 and get HTML back (Checked with FireBug) however i get nothing.

try {
        InputStream myInputStream =null;
        URL url;
        url = new URL("http://www.halebop.se/kontantkort/byt_behall_nummer/#");
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        conn.setDoOutput(true);
        conn.setInstanceFollowRedirects(true);
        conn.setRequestMethod("POST");
        OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
        wr.write("numberToPort="+n+"&action=continue&submit=submit");
        wr.flush();
        myInputStream = conn.getInputStream();
        wr.close();

        BufferedReader rd = new BufferedReader(new InputStreamReader(myInputStream), 4096);
        String line;
        StringBuilder sbResult =  new StringBuilder();
        while ((line = rd.readLine()) != null) {
            sbResult.append(line);
            Log.d(TAG, "Line "+line);
        }
        rd.close();
        String contentOfMyInputStream = sbResult.toString();
        Log.d(TAG, "Output "+contentOfMyInputStream);
    } catch (Exception e) {
        Log.d(TAG,e.getMessage());
    }
  • 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-24T21:26:24+00:00Added an answer on May 24, 2026 at 9:26 pm

    Here is how you can set the post parameters:

                HttpPost httpost = new HttpPost(LOGIN_URL);
        List <NameValuePair> nvps = new ArrayList <NameValuePair>();
        nvps.add(new BasicNameValuePair("test1","test1" ));
        nvps.add(new BasicNameValuePair("test2", "test2" ));
    
                httpost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
    
        response = getResponse(httpost);
    

    Here is the detailed explanation about the code.

    I also explained How to retrieve HTTP cookies from your response and set them into request here

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

Sidebar

Related Questions

I was trying to build Boost C++ Libraries for last two hours and stopped
I have been using Castle MonoRail for the last two years, but in a
I come from more of a Java background. In the last year or two,
Over the last few months/years, I have shared a folder or two with numerous
Is there a way to get a list ordered by two fields, say last
Last year, Scott Guthrie stated You can actually override the raw SQL that LINQ
last time I asked how to populate a data structure here . Now I
Last time I asked about the reverse process , and got some very efficient
Last Friday where I work, an oracle client was upgarded and our IIS server
Last week we released Omniture's analytics code onto a large volume of web sites

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.