News for hackers. Stuff that matters.
Re:Microsoft REST API Guidelines by rubber_duck on Friday November 22, 2019 @06:09PM (#21611090)
I wondered recently - where do large queries fit in to this ? URL encoding has size limits and is inefficient - but you can't use get body
Re:Microsoft REST API Guidelines by jedberg on Friday November 22, 2019 @06:50PM (#21611326)
If you want to be purely restful, you'd POST your request with all the parameters, which would create a new query resource, and then return the query resource ID. You would then make a second GET request with just the query ID.

The GET would be cacheable because they query would be repeatable and idempotent. In theory you'd never have to make the POST more than once unless you are creating a new query, which would make a new ID.

Re:Microsoft REST API Guidelines by rswail on Saturday November 23, 2019 @03:26AM (#21613089)
That would be an operation in this API definition.

See section 13.

Re:Microsoft REST API Guidelines by sojournerc on Friday November 22, 2019 @06:23PM (#21611167)
I use POST for complex queries for this reason. Some things aren't easily URI encoded. Easier to just post JSON. Not pure REST, but I'm not really seeking purity...
Re:Microsoft REST API Guidelines by rubber_duck on Friday November 22, 2019 @06:26PM (#21611180)
Yea that's what everyone does but it seems like a pretty big oversight in REST
Re:Microsoft REST API Guidelines by dragonwriter on Saturday November 23, 2019 @12:13AM (#21612595)
It's not an oversight in REST, it's one of the ways of trying to faithfully implement REST over HTTP, which has a gaping hole in the standard set of methods that messes with that use case. While HTTP (specifically 1.1) is an implementation of REST principles, that use case wasn't front-and-center at the time (PATCH is also a recent fix to another hole.)

There have been proposed standardized fixes such as generalizing the HTTP SEARCH method that first appeared in WebDAV[0], but none have yet gone far.

[0] https://tools.ietf.org/html/draft-snell-search-method-01

Re:Microsoft REST API Guidelines by 19870213 on Friday November 22, 2019 @06:44PM (#21611280)
I suppose you could POST the query object and receive a 201 Created with Location header and then retrieve the results via GET?
Re:Microsoft REST API Guidelines by ben_jones on Friday November 22, 2019 @06:22PM (#21611161)
Or complex nested queries, such as those frequently created in a CRM specifying many key value pairs with different comparators: =, >, <, !=, LIKE. Add complex sorting instructions, pagination instructions, etc.
Re:Microsoft REST API Guidelines by pietrovismara on Friday November 22, 2019 @06:34PM (#21611221)
Technically GET request allow a body in the HTTP spec if I remember correctly. It's just that most implementations don't support it.