News for hackers. Stuff that matters.
Re:Microsoft REST API Guidelines by JMTQp8lwXL on Friday November 22, 2019 @04:36PM (#21610353)
There should be an option for deleting many objects. For that, you have to do a POST request on AWS S3:

https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteOb...

Instead of polluting existing method names to mean new things, HTTP could offer more method names.

Having POST alternatively mean "send a command" makes it meaningless. The command could do anything.

Re:Microsoft REST API Guidelines by paulddraper on Friday November 22, 2019 @06:03PM (#21611054)
> There should be an option for deleting many objects.

What about fetching many objects or creating many objects or updating many objects?

Re:Microsoft REST API Guidelines by littlestymaar on Saturday November 23, 2019 @08:19AM (#21613961)
That's right, that's the same issue. But in both cases, you can just send your list of items to fetch (respectively delete) in the body of the GET or DELETE request. (Because AFAIK, it's HTTP compliant to put a body in a GET request, even if it's rarely used).

Edit: I was wrong. It's allowed to put a body in a GET request, but it isn't OK to use it according to the HTTP spec (which admittedly kind of weird). Source: https://stackoverflow.com/a/983458

Edit2: according to an edit int the SO response, it looks like I wasn't actually wrong: or at least not since 2014 when these RFCs[1][2] became the standard for HTTP.

[1]: https://tools.ietf.org/html/rfc7231#section-4.3.1 [2]: https://tools.ietf.org/html/rfc7230#section-3.3

Re:Microsoft REST API Guidelines by paulddraper on Saturday November 23, 2019 @06:08PM (#21617243)
A body is and has always been syntactically permitted on any HTTP request.

However, it is semantic nonsense to put it on a DELETE or GET.

DELETE is defined to remove the resource identified by the URL; GET is defined to fetch the resource identified by the URL. There no purpose for an entity.

Re:Microsoft REST API Guidelines by littlestymaar on Sunday November 24, 2019 @07:45AM (#21620075)
This is the point made in the SO answer I quoted, and this was the official position of the rfc2616[1], but as I said in my second edit, this rule was relaxed in the new version of the specification: rfc7231 published in 2014.

[1]: https://tools.ietf.org/html/rfc2616#section-9.3 [2]: https://tools.ietf.org/html/rfc7231#section-4.3.1

Re:Microsoft REST API Guidelines by paulddraper on Sunday November 24, 2019 @08:56PM (#21624871)
It looks more or less equivalent the situation previous.

> A payload within a GET request message has no defined semantics

Re:Microsoft REST API Guidelines by littlestymaar on Sunday November 24, 2019 @09:15PM (#21624932)
It went from

> The GET method means retrieve whatever information (in the form of an entity) is identified by the Request-URI.

To :

> A payload within a GET request message has no defined semantics

Which, to me, sounds like: “it was forbidden to put info in the body, and now it's just not especially encouraged”. But maybe I'm over thinking the whole thing.

Re:Microsoft REST API Guidelines by jayd16 on Friday November 22, 2019 @05:41PM (#21610879)
Seems like you could just use Delete with query params on the collection path. Is that not RESTful?
Re:Microsoft REST API Guidelines by JMTQp8lwXL on Friday November 22, 2019 @07:25PM (#21611516)
It doesn't really scale. There's a de-facto limit of 2,000 characters [0] in a URL. HTTP/1.1 is not opinionated about URL length, but practical implementations are.

If your ids are UUIDs, each has a length of 36. If your URL consisted of nothing but UUIDs, you could safely delete 55.5(repeating) of them.

[0]: https://stackoverflow.com/questions/417142/what-is-the-maxim...

Re:Microsoft REST API Guidelines by jimbobenfrance on Saturday November 23, 2019 @09:05AM (#21614155)
I usually implement this as Http delete with a json array of ids in the body.

Probably in violation of some standard, but seems sensible enough.

Re:Microsoft REST API Guidelines by NicoJuicy on Friday November 22, 2019 @09:09PM (#21611956)
Re:Microsoft REST API Guidelines by richardwhiuk on Friday November 22, 2019 @05:53PM (#21610986)
PATCH on the collection.
Re:Microsoft REST API Guidelines by kevin_thibedeau on Friday November 22, 2019 @04:52PM (#21610503)
We don't need a profusion of operations in the core protocol. Do you need idempotence or not? Pick from one of these two things and elaborate on top of that.
Re:Microsoft REST API Guidelines by JMTQp8lwXL on Friday November 22, 2019 @05:00PM (#21610578)
Having "create many", "update many", and "delete many" is three additional operations. Profusion may not be the word I'd use. Also, I will say they are very commonly requested operations, and they've lead to POST becoming overloaded in meaning.
Re:Microsoft REST API Guidelines by ar_lan on Friday November 22, 2019 @05:12PM (#21610672)
Alternatively, in a GraphQL server, everything becomes POST and it all becomes meaningless.
Re:Microsoft REST API Guidelines by felixfbecker on Saturday November 23, 2019 @05:37AM (#21613447)
If you don’t need it to be atomic, you can just make parallel requests. Should not be an issue with HTTP/2
Re:Microsoft REST API Guidelines by charrondev on Saturday November 23, 2019 @04:13PM (#21616592)
Except now your server has to handle a lot more connections.

Was recently dealing with a list of 100+ simple text fields each with unique identifying meta info.

Most usage of the form would only involve updating a few at a time, but on initial entry or a large update all of them could be updated or deleted.

A RESTful approach would have me submit 100+ individual PUT requests. However for a smaller instance of our server it would likely be affected by 100s of requests at a time and it would significantly complicate the client code to make all of these requests at a time and do the error handling for it.

It’s actually a small payload, even with 100 items, so it’s ridiculous to send them individual in order to be “correct” if it

- leads to a worse user experience. - increases load on the server. - complicates the codebase.

Re:Microsoft REST API Guidelines by treve on Friday November 22, 2019 @04:50PM (#21610482)
What advantage is there to having a bulk operation vs many operations?

With HTTP2 you can send a ton of requests in parallel.

Re:Microsoft REST API Guidelines by coldtea on Friday November 22, 2019 @05:47PM (#21610929)
>What advantage is there to having a bulk operation vs many operations?

For one, having it be transactional.

>With HTTP2 you can send a ton of requests in parallel.

That's orthogonal. And they still have a cost (in time and size of transfer).

Re:Microsoft REST API Guidelines by sshumaker on Friday November 22, 2019 @07:01PM (#21611384)
Http2 has efficiency gains at the transport later but not typically at the application tier. Having a single http request lets you things like handling authentication, fetching common state (user object), etc a single time for a batch request. Http2 doesn’t help you here.
Re:Microsoft REST API Guidelines by JMTQp8lwXL on Friday November 22, 2019 @04:58PM (#21610560)
A lot of sites might have an HTTP/2 upstream server, but everything downstream is still communicating via HTTP/1.1. I would imagine you can only the benefits of HTTP/2 multiplexing if you fully utilize HTTP/2 end-to-end.

That means your CDN, your load balancers, and finally your actual applications-- any any other intermediaries -- all communicating via HTTP/2.

Not to say that HTTP/2 isn't the solution, but it's going to be slower than looking up "number of sites using HTTP/2", since you can't easily inspect the behavior of the intermediary servers.

Re:Microsoft REST API Guidelines by treve on Friday November 22, 2019 @05:21PM (#21610745)
Getting onto H2 is worth investing in then though, and drastically simplifies things that would otherwise need bulk operations everywhere.

I'm not entirely sure what you mean with downstream, but in my experience H2 is really well supported almost everywhere these days. Ymmv ofc

Re:Microsoft REST API Guidelines by JMTQp8lwXL on Friday November 22, 2019 @05:34PM (#21610830)
What I mean is, typically, there are many layers between an end user's network request and reaching the server where it will be fulfilled. For example, you might have your site fronted by Cloudflare. They provide DDOS protection, etc. That Cloudflare server might accept HTTP/2 requests, and then open a new request to your load balancer server. Then, your load balancer opens another network request to the server fulfilling the request. The connections between these servers may only support HTTP/1.1. So you lose the benefits of HTTP/2 since you can't multiplex the network request end-to-end.
Re:Microsoft REST API Guidelines by treve on Friday November 22, 2019 @06:12PM (#21611106)
In this particular example (S3), I don't think this is really a concern.

Anyway, I'm curious... what components do you run into that don't support this yet? At least in your examples I can't think of any major players that don't do HTTP/2 out of the box, except, well, old versions.

Is this more of a hypothetical? In my experience HTTP/2 is pretty much ubiquitous for anything current.

Re:Microsoft REST API Guidelines by bebop on Friday November 22, 2019 @09:25PM (#21612014)
There are environments that do not allow http2 or websocket traffic on the network. Most government/big enterprise have these restrictions.
Re:Microsoft REST API Guidelines by felixfbecker on Saturday November 23, 2019 @05:43AM (#21613470)
The load balancer could append a header though with a session ID that is the same for the same HTTP/2 session, and then the server can batch based on the session ID and timeframe.
Re:Microsoft REST API Guidelines by yxhuvud on Saturday November 23, 2019 @02:26AM (#21612919)
Have you ever heard the concept of the common antipattern of n+1 queries that the back-end developers try to avoid? What you are suggesting would create that pattern on the front-end too.
Re:Microsoft REST API Guidelines by treve on Monday November 25, 2019 @07:09AM (#21627363)
Yes, I understand the concept. I totally get that certain situations call for batching operations, including things that need to work transactional.

I think though that most operations don't need this. It's not an optimization I would blindly add to any operation, unless there's a specific case that warrants it.

I don't think that this is an anti-pattern. Most APIs do '1 thing at a time'.

Re:Microsoft REST API Guidelines by felixfbecker on Saturday November 23, 2019 @05:40AM (#21613460)
The backend can batch deletes made in the same timeframe in the same HTTP/2 session, like how you can batch queries with Facebook Dataloader in GraphQL APIs to avoid the n+1 query problem.