xtuple/xtuple — pull request #1354 by bendiy (2014-04-01 20:10:19+00:00)
Title: Add support to query the REST API with a POST body.

This PR adds to dispatchable functions. `XM.Model.query()` which is just a wrapper for `XT.Rest.get()` and `XM.Model.restQuery()` which uses `XM.Model.query()` function to perform a query.

The `XM.Model.restQuery()` allows a REST client to send a query to the API in a POST body instead of over a URL. For example, you can make a POST request to this URL and include the query in the body:

```
POST https://exmaple.com/dev/api/v1alpha1/services/model/rest-query
```

Without this, you have to make a complex query over a GET URL. nginx has a limit on the length of the URL. If you reach that limit, nginx will send a "414 Request URI Too Large" error. This query is for database ids, but imagine what happens when I query on UUIDs.

```
GET https://exmaple.com/dev/api/v1alpha1/resources/xdruple-commerce-product?query%5Bproduct_id%5D%5BANY%5D%5B0%5D=360&query%5Bproduct_id%5D%5BANY%5D%5B1%5D=349&query%5Bproduct_id%5D%5BANY%5D%5B2%5D=351&query%5Bproduct_id%5D%5BANY%5D%5B3%5D=352&query%5Bproduct_id%5D%5BANY%5D%5B4%5D=353&query%5Bproduct_id%5D%5BANY%5D%5B5%5D=354&query%5Bproduct_id%5D%5BANY%5D%5B6%5D=355&query%5Bproduct_id%5D%5BANY%5D%5B7%5D=356&query%5Bproduct_id%5D%5BANY%5D%5B8%5D=357&query%5Bproduct_id%5D%5BANY%5D%5B9%5D=358&query%5Bproduct_id%5D%5BANY%5D%5B10%5D=359&query%5Bproduct_id%5D%5BANY%5D%5B11%5D=361&query%5Bproduct_id%5D%5BANY%5D%5B12%5D=362&query%5Bproduct_id%5D%5BANY%5D%5B13%5D=363&query%5Bproduct_id%5D%5BANY%5D%5B14%5D=364&query%5Bproduct_id%5D%5BANY%5D%5B15%5D=365&query%5Bproduct_id%5D%5BANY%5D%5B16%5D=366&query%5Bproduct_id%5D%5BANY%5D%5B17%5D=367&query%5Bproduct_id%5D%5BANY%5D%5B18%5D=368&query%5Bproduct_id%5D%5BANY%5D%5B19%5D=369&query%5Bproduct_id%5D%5BANY%5D%5B20%5D=370&query%5Bproduct_id%5D%5BANY%5D%5B21%5D=371&query%5Bproduct_id%5D%5BANY%5D%5B22%5D=372&query%5Bproduct_id%5D%5BANY%5D%5B23%5D=373&query%5Bproduct_id%5D%5BANY%5D%5B24%5D=374&query%5Bproduct_id%5D%5BANY%5D%5B25%5D=375&query%5Bproduct_id%5D%5BANY%5D%5B26%5D=350&count=true
```
The POST body object uses the exact same structure as the GET query object. It is up the the REST client to determine which HTTP method to use when making a query.