Description
@stewart-ibm was complaining that his script to update patch states via the REST API wasn't working.
His script was POSTing the update to "/api/patches/$NUMBER", and receiving an HTTP 200 in response, but no update.
I did some digging and discovered that when you access "/api/patches/$NUMBER", you get back a 301 Moved Permanently to "/api/patches/$NUMBER/" (note trailing slash). It seems that when you do a POST and get a 301 in response, the behaviour is to try a GET on the redirected URL, rather than a POST.
Once I figured this out, I tried doing a POST on the correct URL with the trailing slash, got a 405 Method Not Allowed, and quickly realised the real problem was that we should have been doing a PATCH.
For good measure, I checked what happens when you send a PATCH without the trailing slash, you get a 301, my logs seem to indicate that the subsequent request to the 301 target URL is still a PATCH, yet for some reason the state doesn't update. Not sure why.
Anyway, the trailing slash thing is really confusing and I'm not sure if it's semantically appropriate for accessing an individual object.
Thoughts?