httpverbs

Python Requests - Dynamically Pass HTTP Verb

戏子无情 提交于 2020-08-24 05:50:07
问题 Is there a way to pass an HTTP verb (PATCH/POST) to a function and dynamically use that verb for Python requests? For example, I want this function to take a 'verb' variable which is only called internally and will either = post/patch. def dnsChange(self, zID, verb): for record in config.NEW_DNS: ### LINE BELOW IS ALL THAT MATTERS TO THIS QUESTION json = requests.verb(headers=self.auth, url=self.API + '/zones/' + str(zID) + '/dns_records', data={"type":record[0], "name":record[1], "content"

Incrementing resource counter in a RESTful way: PUT vs POST

泪湿孤枕 提交于 2020-08-20 23:10:24
问题 I have a resource that has a counter. For the sake of example, let's call the resource profile , and the counter is the number of views for that profile. Per the REST wiki, PUT requests should be used for resource creation or modification, and should be idempotent. That combination is fine if I'm updating, say, the profile's name, because I can issue a PUT request which sets the name to something 1000 times and the result does not change. For these standard PUT requests, I have browsers do

Incrementing resource counter in a RESTful way: PUT vs POST

醉酒当歌 提交于 2020-08-20 23:08:07
问题 I have a resource that has a counter. For the sake of example, let's call the resource profile , and the counter is the number of views for that profile. Per the REST wiki, PUT requests should be used for resource creation or modification, and should be idempotent. That combination is fine if I'm updating, say, the profile's name, because I can issue a PUT request which sets the name to something 1000 times and the result does not change. For these standard PUT requests, I have browsers do

How to model a CANCEL action in a RESTful way?

落花浮王杯 提交于 2020-03-18 04:12:21
问题 We are currently in the process of wrangling smaller services from our monoliths. Our domain is very similar to a ticketing system. We have decided to start with the cancellation process of the domain. Our cancel service has as simple endpoint "Cancel" which takes in the id of the ticket. Internally, we retrieve the id, perform some operations related to cancel on it and update the state of the entity in the store. From the store's perspective the only difference between a cancelled ticket

How to model a CANCEL action in a RESTful way?

青春壹個敷衍的年華 提交于 2020-03-18 04:09:54
问题 We are currently in the process of wrangling smaller services from our monoliths. Our domain is very similar to a ticketing system. We have decided to start with the cancellation process of the domain. Our cancel service has as simple endpoint "Cancel" which takes in the id of the ticket. Internally, we retrieve the id, perform some operations related to cancel on it and update the state of the entity in the store. From the store's perspective the only difference between a cancelled ticket

What are practical use-cases for the HTTP verb REPORT and why is it neglected over time?

安稳与你 提交于 2020-03-18 03:52:27
问题 Whenever I have to create a RESTful web service and the use case implies on getting data based on a set of search criteria, I always opted for a POST request with the parameters in the body instead of a GET request for all the obvious reasons. I've seen it a dozen of times so I figured is was best practice. Most recently I stumbled upon this interesting blog article by Evert Pot where he comments on the downsides of the POST verb and simply notes on using the REPORT verb instead. He also

How to automatically overload DELETE and PUT if they are not available by the client?

对着背影说爱祢 提交于 2020-01-01 19:12:08
问题 How can I detect at the startup of the application that a client doesn't support DELETE and PUT verbs and automatically overload the POST verb? On the server side, how can I redirect those overloaded POST verbs into the right actions? Say I have a DELETE request that is overriden, how do I call the appropriate function in the controller that matches the action? My guess is that I should use some action filter and use reflection to inspect the attributes that matches my function (in this

How to specify DELETE method in a link or form?

混江龙づ霸主 提交于 2019-12-30 05:32:09
问题 Rfc2616 lists many methods besides GET and POST, like, say, DELETE, PUT etc. Method field in html forms, though, seems to be allowed to specify only GET or POST. Is it possible to create a link or form in a html page that uses a request method that is not GET or POST? 回答1: You certainly can’t create a link that uses anything other than GET . Since HTML began, links have been meant to be idempotent and free from side effects. For forms and XMLHTTPRequests , Caps’ link is the place to look: Are

Are REST API's really RESTful?

左心房为你撑大大i 提交于 2019-12-21 20:54:35
问题 I'm new to this game so I might be misunderstanding things. Actually, if someone tells me that I'm misunderstanding things, it will be a favor. Maybe this person will be considerate enough to show me the right path. But... One of the " guidelines " or " best practices " of REST as it applies to Web Services (http://en.wikipedia.org/wiki/Representational_state_transfer#Applied_to_web_services) is that you should use the proper HTTP methods when making calls (did I misunderstand it?) to REST

Using POST as a workaround for the URL character limit

假如想象 提交于 2019-12-21 03:56:11
问题 If you have an API and support the POST operation only because of URL length limitations and the passing of complex parameters in the request, can you still say that you have a RESTful architecture? What the above basically implies is that for this particular (read-only) API, there is no semantic difference between a GET and a POST, so what can be done with a GET can also be done with a POST (but not vice versa due to the limitations). Would this still make the style of the architecture a