Note that there are some explanatory texts on larger screens.

plurals
  1. POIIS seems to think an Android HttpPost is a GET
    primarykey
    data
    text
    <p><em>UPDATE: These problems were caused by a reverse proxy performing a 301 redirect. Altering the url to the destination of the redirect fixed the issue.</em></p> <p>I am struggling to make a POST request from android to a web service.</p> <p>I have a web service running on IIS7 with the following:</p> <pre><code>&lt;OperationContract()&gt; _ &lt;Web.WebInvoke(BodyStyle:=WebMessageBodyStyle.Bare, Method:="POST", RequestFormat:=WebMessageFormat.Xml, ResponseFormat:=WebMessageFormat.Xml, UriTemplate:="HelloWorld")&gt; _ Function HelloWorld() As XmlElement </code></pre> <p>When I send a POST request to this url from Firefox it works as expected.</p> <p>When I make the request from an Android device using the following code:</p> <pre><code>String sRequest = "http://www.myserviceurl.com/mysevice/HelloWorld"; ArrayList&lt;NameValuePair&gt; arrValues = new ArrayList&lt;NameValuePair&gt;(); arrValues.add(new BasicNameValuePair("hello", "world")); HttpClient httpClient = new DefaultHttpClient(); HttpPost httpRequest = new HttpPost(sRequest); httpRequest.setHeader("Content-Type", "application/x-www-form-urlencoded"); httpRequest.setEntity(new UrlEncodedFormEntity(arrValues)); HttpResponse response = httpClient.execute(httpRequest); </code></pre> <p>I get a Method Not Allowed 405 response and when looking in the IIS logs the request to this url appears as a "GET".</p> <p>If I change the target of the request to a PHP script that echoes $_SERVER['REQUEST_METHOD'] the output is POST.</p> <p>The web.config of the web service has GET, HEAD and POST as verbs.</p> <p>Is there something I have overlooked?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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