Re:Tesla Model S JSON API
by noonespecial on Sunday June 29, 2014 @09:34PM
(#7963242)
Ahh. Good point. I was considering PUTting the horn into the honking state vs POSTing horn honks for execution. In the first case, 2 PUT honks would just result in a honking car, in the second, 2 POSTs would get you 2 "honks" whatever those are defined to be.
I guess I was thinking of the idempotent "panic" button on my cars key fob.
the idempotent "panic" button on my cars key fob
Hmmm, mine actually isn't--one hit turns panic mode on, the second turns it off.
There's a reasonable argument for a custom verb.
But pragmatically, given the problems customs verbs cause I'd probably go for POST.
Re:Tesla Model S JSON API
by daurnimator on Sunday June 29, 2014 @11:48PM
(#7963613)
Actually it's 7231 now ;) http://tools.ietf.org/html/rfc7231#section-4
The main problem with using PUT is that PUT is supposed to be idempotent; the result of two PUTs with the same content should be the same as the result of a single PUT with that content. But two PUTs to honk the horn would honk the horn twice, not once.
Since we're all being pedantic about HTTP methods here, we should have a link to RFC 2616 :)
http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html