title: App Engine : 400 - Your client has issued a malformed or illegal request
body: <p>I have been running into this error for the last 3 or 4 weeks making requests to app engine. Certain requests - especially HTTP DELETE requests, are having this error returned from the google server.</p>
  
  <p>Others have reported the same error - with 3 outcomes I can locate</p>
  
  <ol>
  <li>It is caused by stale cookies - clear your cookies and it runs fine <a href="http://mail.google.com/support/bin/answer.py?hl=en&amp;answer=91343" rel="noreferrer">gmail help</a> -</li>
  <li>It is caused by a malformed url - only cases I can find relate to urlfetch() - spaces in the url - <a href="http://groups.google.com/group/google-appengine/browse_thread/thread/22f3b4c9ca8ad9ce/2f6f16bc52e9f904" rel="noreferrer">App engine Group #1</a>, <a href="http://groups.google.com/group/google-appengine/browse_thread/thread/8e4f4aa3378743a/b94732257aa50349" rel="noreferrer">App Engine Group #2</a></li>
  <li>No resolution - sporadic behaiour, IE only. <a href="http://groups.google.com/group/google-appengine/browse_thread/thread/ddc57afff119a132/1cdcd582a5b1dd95" rel="noreferrer">App Engine Group #3</a>, <a href="http://groups.google.com/group/google-appengine/browse_thread/thread/1f96d9bdfa35e838/ba9ae76bc3de4b46" rel="noreferrer">App Engine Group #4</a></li>
  </ol>
  
  <p>I'm now getting this behaviour all the time, in every browser. I can completely clear down the cache/cookies etc. in Chrome, Firefox, Safari, restart the browser and still reliably get this error on the same requests, so I don't think its cookie related.  In any case I can issue GET, POST &amp; PUT requests no problem with the same cookie.</p>
  
  <p>Given that it occurs reliably on specific DELETE requests, the malformed URL would seem the most likely, however my URL is really very simple, and works fine on the dev server</p>
  
  <p>Firebug shows the request headers as (I've munged the keys as they contain identifying data, but did so by removing characters from the centre of the key - not either end to guarantee I didn't inadvertently remove any leading or trailing whitespace)</p>
  
  <pre><code>    Request URL:http://my-app.appspot.com/agprhcjgLEgVLbm93dCItX0RrbV9Ea25vd3RfbmV0X19wccxDA/Task.xml
      Request Method:DELETE
      Status Code:400 Bad Request
  
      Request Headers
      Accept:*/*
      Cache-Control:max-age=0
      Content-Type:application/x-www-form-urlencoded
      Origin:http://my-app.appspot.com
      Referer:http://my-app.appspot.com/
      User-Agent:Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.99 Safari/533.4
      X-Requested-With:XMLHttpRequest
  
      Form Data
      entity_key:agprdC1hcjYLEgVLbm93dCIrX09Ea25vd3RfbmV0X19wMQw
  
      Response Headers
      Content-Length:1350
      Content-Type:text/html; charset=UTF-8
      Date:Fri, 30 Jul 2010 15:51:58 GMT
      Server:GFE/2.0
  </code></pre>
  
  <p>The response headers show that the request never made it to the app engine servers (and my app engine logs bear this out) - a request which successfully makes it to the app engine server looks more like this for response headers -</p>
  
  <pre><code>Cache-Control:no-cache
  Content-Length:4332
  Content-Type:application/xml
  Date:Fri, 30 Jul 2010 11:08:21 GMT
  Expires:Fri, 01 Jan 1990 00:00:00 GMT
  Server:Google Frontend
  X-AppEngine-Estimated-CPM-US-Dollars:$0.004033
  X-AppEngine-Resource-Usage:ms=573 cpu_ms=146 api_cpu_ms=30
  </code></pre>
  
  <p>I am constructing the requests using jquery's $.ajax() method and setting the type as 'DELETE'.  Also, these have worked as recently as last week, although the problem was starting to appear intermittently.  Right now, nothing I do has any effect.</p>
  
  <p>At the moment I'm thinking this is some sort of configuration error/change on google servers , slowly creeping across their network - which explains why it began intermittently, steadily increased, and now happens all the time.</p>
  
  <p>Is anyone else able to issue HTTP DELETE requests to google app engine? If you are, do your URL's contain app engine entity keys? Can you see anything dodgy with mine?</p>
  
  <p>Any other pointers would be greatly appreciated.  Cheers,</p>
  
  <p>Colin</p>
  
  <p>The full response from the google server is -</p>
  
  <pre><code>&lt;html&gt;&lt;head&gt;
  &lt;meta http-equiv="content-type" content="text/html;charset=utf-8"&gt;
  &lt;title&gt;400 Bad Request&lt;/title&gt;
  &lt;style&gt;&lt;!--
  body {font-family: arial,sans-serif}
  div.nav {margin-top: 1ex}
  div.nav A {font-size: 10pt; font-family: arial,sans-serif}
  span.nav {font-size: 10pt; font-family: arial,sans-serif; font-weight: bold}
  div.nav A,span.big {font-size: 12pt; color: #0000cc}
  div.nav A {font-size: 10pt; color: black}
  A.l:link {color: #6f6f6f}
  A.u:link {color: green}
  //--&gt;&lt;/style&gt;
  &lt;script&gt;&lt;!--
  var rc=400;
  //--&gt;
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body text=#000000 bgcolor=#ffffff&gt;
  &lt;table border=0 cellpadding=2 cellspacing=0 width=100%&gt;&lt;tr&gt;&lt;td rowspan=3 width=1% nowrap&gt;
  &lt;b&gt;&lt;font face=times color=#0039b6 size=10&gt;G&lt;/font&gt;&lt;font face=times color=#c41200 size=10&gt;o&lt;/font&gt;&lt;font face=times color=#f3c518 size=10&gt;o&lt;/font&gt;&lt;font face=times color=#0039b6 size=10&gt;g&lt;/font&gt;&lt;font face=times color=#30a72f size=10&gt;l&lt;/font&gt;&lt;font face=times color=#c41200 size=10&gt;e&lt;/font&gt;&amp;nbsp;&amp;nbsp;&lt;/b&gt;
  &lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td bgcolor="#3366cc"&gt;&lt;font face=arial,sans-serif color="#ffffff"&gt;&lt;b&gt;Error&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
  &lt;blockquote&gt;
  &lt;H1&gt;Bad Request&lt;/H1&gt;
  Your client has issued a malformed or illegal request.
  
  &lt;p&gt;
  &lt;/blockquote&gt;
  &lt;table width=100% cellpadding=0 cellspacing=0&gt;&lt;tr&gt;&lt;td bgcolor="#3366cc"&gt;&lt;img alt="" width=1 height=4&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
  &lt;/body&gt;&lt;/html&gt;
  </code></pre>