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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:37:52+00:00 2026-05-24T11:37:52+00:00

Ok this will be a long one, so thx for all who are reading

  • 0

Ok this will be a long one, so thx for all who are reading this to the end.

Precondition: I can’t access the server, I’m just trying to post data as a news comment.

I’m desperately testing this out for a couple of hours now but I still don’t have any success. What I basically need is this kind of request:

POST http://www.example.com/gen/processtalkback.php
Cookie: userid=XXXX; password=XXXX
Content-Type: application/x-www-form-urlencoded
reference_id=XXXX&talkback_command=newentry&talkback_content=comment&talkback_viewpage=1&reference_area=11

So nothing special, just two headers with two cookies and a content discriptor and five parameters.
The two cookies are mandatory, so I set them like this:

CookieStore cookieStore = httpClient.getCookieStore();

BasicClientCookie cookie = new BasicClientCookie("userid", "XXXX");
cookie.setDomain("http://www.example.com");
cookieStore.addCookie(cookie);

BasicClientCookie cookie2 = new BasicClientCookie("password", "XXXX");
cookie2.setDomain("http://www.example.com");
cookieStore.addCookie(cookie2);

After that I set the header and content to the HttpPost object and execute it:

HttpPost httpost = new HttpPost("http://www.example.com/gen/processtalkback.php");
httpost.setHeader("Content-Type", "application/x-www-form-urlencoded");
List<NameValuePair> nvps = new ArrayList<NameValuePair>(5);
nvps.add(new BasicNameValuePair("reference_id", "XXXX"));
...
httpost.setEntity(new UrlEncodedFormEntity(nvps));

HttpResponse httpResponse = httpClient.execute(httpost);

I look into the response and it shows me:

Log.i("RESPONSE", httpResponseActivity.getStatusLine() + EntityUtils.toString(httpResponse .getEntity()));

HTTP/1.1 417 Expectation Failed
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
     <title>417 - Expectation Failed</title>
    </head>
    <body>
     <h1>417 - Expectation Failed</h1>
    </body>
</html>

I really don’t know what the problem is. With Firefox Extensions like “poster” or “HttpRequester” I succeed with the posting:

POST http://www.example.com/gen/processtalkback.php
Cookie: userid=XXXX; password=XXXX
Content-Type: application/x-www-form-urlencoded
reference_id=XXXX&talkback_command=newentry&talkback_content=comment&talkback_viewpage=1&reference_area=11

200 OK
X-Powered-By:  PHP/5.3.6
Set-Cookie:  ...
Expires:  Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control:  no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma:  no-cache
Content-Type:  text/html; charset=utf-8
Transfer-Encoding:  chunked
Date:  Sun, 07 Aug 2011 16:24:01 GMT
Server:  lighttpd/1.4.22
 <a name="commentanchor"></a>
...

I also tried it with a Parameter object but still no success:

HttpParams params = new BasicHttpParams();          
params.setParameter("reference_id", "XXXX");
...
httpost.setParams(params);

What could be the cause of the problem? Am I missing something? Any Apache HttpClient specifics I’m unaware of? I’m aware of the fact that the server is telling me something by this failure, so I searched in the web and tried one of the solutions for this:

params.setBooleanParameter("http.protocol.expect-continue", false);

Still no success.

What I got from wiretapping by the app “shark for root” without this parameter:

Data:
POST /gen/processtalkback.php
HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Content-Length: 119
Host: www.example.com
Connection: Keep-Alive
User-Agent: Apache-HttpClient/UNAVAILABLE (java 1.4)
Expect: 100-Continue

HEX: .....

And now with the parameter:

Data:
POST /gen/processtalkback.php
HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Content-Length: 119
Host: www.example.com
Connection: Keep-Alive
User-Agent: Apache-HttpClient/UNAVAILABLE (java 1.4)
reference_id=XXXX...............

HEX: .....

What I got by firebug from posting by browser:

Host    www.example.de
User-Agent  Mozilla/5.0
Accept  text/javascript, text/html, application/xml, text/xml, */*
Accept-Language en-us,de-de;q=0.8,en;q=0.5,de;q=0.3
Accept-Encoding gzip, deflate
Accept-Charset  ISO-8859-1,utf-8;q=0.7,*;q=0.7
DNT 1
Connection  keep-alive
X-Requested-With    XMLHttpRequest
X-Prototype-Version 1.7
Content-Type    application/x-www-form-urlencoded; charset=UTF-8
Referer ...
Content-Length  134
Cookie  ...
Pragma  no-cache
Cache-Control   no-cache

Why won’t the cookies be displayed in my programmatic httppost attempts? It would be awesome if someone would have an idea. 🙂

  • 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-24T11:37:52+00:00Added an answer on May 24, 2026 at 11:37 am

    Got it working with another approach. I used this code of a German forum posting: http://www.android-hilfe.de/android-app-entwicklung/6398-http-post-request-mit-cookie.html

    So I basically had to write

    URL url = new URL("http://www.example.com/gen/processtalkback.php");
    
    HttpURLConnection connection = (HttpURLConnection) url.openConnection();
    connection.setDoOutput(true);
    connection.setRequestMethod("POST");
    connection.setRequestProperty("Cookie", "userid=XXXX; password=XXXX");
    connection.connect();
    

    Shark dump:

    Data:
    POST /gen/processtalkback.php
    HTTP/1.1
    cookie: userid=XXXX; password=XXXX
    User-Agent: Dalvik/1.2.0 (Linux; U; Android 2.2.2; ...
    Host: www.example.com
    Connection: Keep-Alive
    Content-Type: application/x-www-form-urlencoded
    Content-Length: 119
    
    HEX: .....
    

    Post content was send seperately:

    Data:
    reference_id=XXXX&talkback_command=newentry&talkback_content=comment&talkback_viewpage=1&reference_area=11
    
    HEX: .....
    

    And it worked perfectly!
    I’m really confused why this approach was successful at the very first time and trying it with the Apache HttpClient for hours resulted in literally tearing my hair out.

    Does anyone know more details? I would very much appreciate any explanation.

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

Sidebar

Related Questions

This will be a long one but I hope you could bear with me.
It might be a long shot posting this question here but we will see.
This will hopefully be an easy one. I have an F# project (latest F#
This will probably be obvious but I can't find the best way. I want
Ok saddle up cowboys, because this is going to be a long one. I
Take a guess ... how long will this program take to produce the very
Will this fail ? Resharper reports this as an instance of Access to modified
This my friends, is a going to be long one... I am getting some
I know ASIHTTPRequest works perfectly well with HTTPS. All we need is this one
this post is a long one sorry for that but the problem is complex

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.