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 have been trying to validate my web page for the last two hours,
I've been trying to solve these problem for last two hours but seems like
I've been trying to solve this for the past two hours and couldn't do
I was trying to build Boost C++ Libraries for last two hours and stopped
So I've been using Erlang for the last eight hours, and I've spent two
I have been googling and stackoverflowing for the last two hours and couldn't find
This problem has kept me busy for the last hours. I have two sections
I've been looking at this for the last few hours, and can't really achieve
I have been researching for the last two hours, and have found nothing. Basically,
I have been using Castle MonoRail for the last two years, but in a

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.