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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:50:44+00:00 2026-06-14T14:50:44+00:00

Alright, so the http post of the c# code works(the function returns TRUE ,

  • 0

Alright, so the http post of the c# code works(the function returns TRUE, means the response string is “OK“, here it is:

public bool Rank(int rank)
    {
                    System.Text.UTF8Encoding encoding=new System.Text.UTF8Encoding();
        string postData = "";
        InvokeOnMainThread(delegate(){
        postData="pass=somePass&request=someRequest&access_key="+((FBTabBarController)TabBarController).AAMAccessKey+"&pid="+place_id+"&rank="+rank.ToString();
        });
byte[]  data = encoding.GetBytes(postData);

                HttpWebRequest myRequest =
            (HttpWebRequest)WebRequest.Create("someURL");
myRequest.Method = "POST";
myRequest.ContentType="application/x-www-form-urlencoded";
myRequest.ContentLength = data.Length;
Stream newStream=myRequest.GetRequestStream();
// Send the data.
newStream.Write(data,0,data.Length);
newStream.Close();
        HttpWebResponse hwr =(HttpWebResponse) myRequest.GetResponse();
        StreamReader reader = new StreamReader(hwr.GetResponseStream());
        string res = reader.ReadToEnd();
        if(res=="OK") 
            return true;}
        else if(res == "FAILED") return false;

        return false;
    }

And here’s the JAVA code that isn’t working(the function returns FALSE for the same parameters as the code above, the response string is: NULL :

   public boolean SubmitRank(String URL) 
    {
        HttpClient httpclient = new DefaultHttpClient();   
        HttpPost httppost = new HttpPost(URL); 
            // Add your data   

            List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(5); 
            Log.d("MyTag","id: " + place_id + "rank: " + rank);
            nameValuePairs.add(new BasicNameValuePair("pass","somePass"));
            nameValuePairs.add(new BasicNameValuePair("request","someRequest"));
            nameValuePairs.add(new BasicNameValuePair("accesskey",shareAppPreferences.getAccessKey()));
            nameValuePairs.add(new BasicNameValuePair("pid",place_id));
            nameValuePairs.add(new BasicNameValuePair("rank",rank));

            try {
                    httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs,HTTP.UTF_8));
                    try {
                       HttpResponse response = httpclient.execute(httppost);
                        String resString = EntityUtils.toString(response.getEntity());

                        if(resString.equals("OK")){
                            return true;
                        }
                        else if(resString.equals("FAILED")){
                            return false;
                        }
                        return false;
                    } catch (ClientProtocolException e) {
                        e.printStackTrace();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                } catch (UnsupportedEncodingException e) {
                    e.printStackTrace();
                }
            return false;
    }

Why the JAVA code isn’t working while the C# code is working? Am I missing anything in the above request?

  • 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-14T14:50:45+00:00Added an answer on June 14, 2026 at 2:50 pm

    What’s the HTTP status code being returned? You can this obtained via response.getStatusLine().getStatusCode() method. This will help you pin point the possible issue, like is the request even making it to the server.

    Otherwise, the way you’re creating and sending your HTTP request in the Java code looks correct and valid.

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

Sidebar

Related Questions

Alright, here I am again trying to write code from scratch and I can't
I'm trying to generate ics-files, see sample here: http://deap.nu/myprogram.ics It validates alright here: https://icalendar.org/validator.html
Alright, I just got finished making a function for some code I'm making, which
Alright, here is a link to the site I am working on. http://danberinger.com/preview.html I
Alright, here's the site in question: http://abramobile.com If you scroll down the page past
Alright so I am new here so I apologize in advance if I post
Alright, so I downloaded the SpiderMonkey source code using the command wget http://ftp.mozilla.org/pub/mozilla.org/js/js185-1.0.0.tar.gz and
Alright, so here is what I'm hoping for... Any request to this http://www.fileorchard.com/3451928347592 will
Alright, I have a server that serves a motion-jpeg stream over http. What I
Alright I don't see why this isnt working. It seems pretty simple. Here is

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.