HTTP Method Override
The use of a GET request to search for matching records is part of the standard REST API based paradigm. An issue arises when the length of the URL generated is too large and is either truncated in transmission or rejected by the server. In order to get around this issue the HTTP Method Override extension was created. It allows almost infinite length requests to be sent by changing the request to a POST and sending the query parameters in the payload.
There are a few HTTP headers required to inform the shim that the extension is being used. The headers are:
Header | Value |
---|---|
X-HTTP-Method-Override | GET |
Content-Type | application/x-www-form-urlencoded |
The payload of the request is then the URL Encoded query string, without the leading question mark.
As an example consider sending a GET request to the EMu eparties resource with the following settings:
filter
{
"AND": [
{
"data.NamLast": {
"exact": {
"value": "Smith"
}
}
}
]
}
sort
[
{
"data.NamFirst": {
"order":"asc"
}
},
{ "data.NamLast":
{
"order":"desc"
}
}
]
select
data.NamLast,data.NamFirst
limit
10
To use the HTTP Method Override extension the following request is required:
URI
POST /museum/eparties
Headers
X-HTTP-Method-Override: GET
Content-Type: application/x-www-form-urlencoded
Authorization: Bearer {token}
Prefer: representation=minimal
Body
sort=%5B%0A%20%20%7B%0A%20%20%20%20%22data.NamFirst%22%3A%20%7B%0A%20%20%20%20%20%20%22order%22%3A%22asc%22%0A%20%20%20%20%7D%0A%20%20%7D%2C%0A%20%20%7B%20%22data.NamLast%22%3A%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%22order%22%3A%22desc%22%0A%20%20%20%20%7D%0A%20%20%7D%0A%5D&limit=10&filter=%7B%0A%20%20%22AND%22%3A%20%5B%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%22data.NamLast%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22exact%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%22value%22%3A%20%22Smith%22%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%5D%0A%7D%0A&select=data.NamLast%2Cdata.NamFirst
The body contains the URL encoded query parameters, without the leading question mark.
In order to avoid issues with URL lengths it is recommended that all EMu resource GET requests are submitted using the HTTP Method Override extension.