I am working with an API that requires me to make an HTTP PATCH request as part of the URI, is this possible to do from Javascript, my research is showing that I can only do POST, GET, DELETE, and PUT. Is PATCH allowed?
Thank you,
I am working with an API that requires me to make an HTTP PATCH request as part of the URI, is this possible to do from Javascript, my research is showing that I can only do POST, GET, DELETE, and PUT. Is PATCH allowed?
Thank you,
Share Improve this question asked Sep 21, 2011 at 15:16 NSANSA 6,03710 gold badges39 silver badges51 bronze badges 2- 1 Most browsers limit the HTTP Methods to POST/GET, support for others are patchy, for instance IE9 does Delete, I haven't seen it in every browser however. For best results, re-phrase your question about browser support for HTTP Methods. – Incognito Commented Sep 21, 2011 at 15:42
- 5 Browser limits to POST/GET apply to HTML form submission, not XmlHttpRequest. – Julian Reschke Commented Sep 21, 2011 at 20:11
2 Answers
Reset to default 6I'm not sure what you exactly mean by a "PATCH" request, but it seems to be possible (at least in Firefox 6 and Chromium 12). According to the Mozilla source code, there is only a limitation of TRACE
and TRACK
requests.
A quick testcase:
<!-- test.html -->
<script>
var x=new XMLHttpRequest();
x.open("patch", "/");
x.send(null);
</script>
Any webserver can be used, but I choose for Python's SimpleHTTPServer module.
$ ls
test.html
$ python -m SimpleHTTPServer
localhost - - [21/Sep/2011 17:32:11] "GET /test.html HTTP/1.1" 200 -
localhost - - [21/Sep/2011 17:32:11] code 501, message Unsupported method ('patch')
localhost - - [21/Sep/2011 17:32:11] "patch / HTTP/1.1" 501 -
So, as long as the server supports the method, the request get's passed.
As of some research the PATCH
method seems to be new (march 2010 https://www.rfc-editor/rfc/rfc5789) so if you try to define PATCH
on an XMLHttpRequest it may work, but only on very latest revisions of modern browsers. Don't have a supported browser list found, yet.