Note that there are some explanatory texts on larger screens.

plurals
  1. POAuthentication Error when using HttpPost with DefaultHttpClient on Android
    text
    copied!<p>I'm running into a strange problem using HttpClient. I am using a DefaultHttpClient() with HttpPost. I was using HttpGet with 100% success but now trying to switch to HttpPost as the REST API I'm using wants POST parameters rather than GET. (Only for some API calls though so I know that the GET calls were working fine so it's not a fault of the API).</p> <p>Also, I tried using HttpPost on a simple php script I wrote that looks for a POST parameter 'var' and echoes it to screen, passing this parameters as follows worked fine:</p> <pre><code>List&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;(); postMethod = new HttpPost("http://www.examplewebsite.com"); nameValuePairs.add(new BasicNameValuePair("var", "lol")); try { postMethod.setEntity(new UrlEncodedFormEntity(nameValuePairs)); response = httpClient.execute(postMethod, responseHandler); Log.i("RESTMethod", response); ... </code></pre> <p>The problem is that when I tried and do the same call to the API (but with the params changed to the API params obviously) I get the following error:</p> <pre><code>Authentication error: Unable to respond to any of these challenges: {} </code></pre> <p>The page I am requesting is an HTTPS page, could this be the problem?</p> <p>But doing the same type of POST request to a raw HTTP page on the API gives the same error, unless I comment out the StringEntity part and then it runs (but returns xml and I want to pass a parameter to request the data in JSON).</p> <p>This seems like a really strange problem (the non-https part) but couldn't really find any help on this problem so sorry if the answer is out there.</p> <p>Any ideas?</p> <p>Thanks in advance,</p> <p>Infinitifzz</p> <p>EDIT: Okay I'm getting nowhere so I thought if I directed you to the API it might shed some light, it's the <a href="http://8tracks.com/developers/api">8Tracks API</a> and as you can see you need to pass a dev key (api_key) for all requests and I the part I'm stuck on is using https to log a user in with: <a href="http://www.8tracks.com/sessions.xml">http://www.8tracks.com/sessions.xml</a>" part.</p> <p>Hope this helps somehow because I am at a dead end.</p> <p>Thanks,</p> <p>Infinitifizz</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload