How to set httppost header for client requests in Java and Android
I can't get Apache httpclient to send httppost header correctly
I have no problem sending name value pairs and things like that, but whenever I set or add a post header, it disappears when the request occurs
I have tried setheader and AddHeader, and tried both at the same time
This is my code:
HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost("https://posttestserver.com/post.PHP"); httppost.setHeader("Authorization: Bearer",accessToken); httppost.addHeader("Authorization: Bearer",accessToken); Log.d("DEBUG","HEADERS: " + httppost.getFirstHeader("Authorization: Bearer")); ResponseHandler<String> responseHandler = new BasicResponseHandler(); String responseBody = httpclient.execute(httppost,responseHandler); Log.d("DEBUG","RESPONSE: " + responseBody);
In addition, the debug statement before executing the request prints out the correct title, so I know it is being added and then deleted later
Any help will be appreciated!
Edit: if it's important, it all runs in asynctask I don't think so, because a networkonmainthread exception was thrown, but I think it's worth mentioning
Solution
Try to connect to the service of tell your HTTP headers and capture (print only plain HTML) output At least you will know whether your title is really lost or something else