Consuming HTTP Services in Python Transcripts
Chapter: Consuming RESTful HTTP services
Lecture: Concept: Deleting a post with requests

Login or purchase this course to watch this video and the rest of the course contents.
0:01 It probably won't surprise you to hear that to delete a blog post we are going to issue an http request to the blog post url with the delete verb.
0:11 So this is a very simple request, we are just going to say delete/api/blog/id and the response is not going to be any data just 202 that worked.
0:20 In code, again, this is probably the simplest of the 4 operations that we're doing, with working with data here, including get.
0:28 So we come up with the url, api/blog/post id and then we're going to issue an http request with a delete verb
0:36 and we're just going to issue it straight to that url, nothing else is required,
0:40 and all that is left is to determine did that work, or did it not work, so in our case, the right response code, or the expected response code is 202
0:47 from the server, you may also want to be on the lookout for 200s if whoever wrote the API is not super careful about status codes,
0:54 or 204 is another reasonable response code that could mean success, it's unlikely this will vary over time for particular API,
1:02 it's just that they may have made a different choice than 202. So you want to check here and then if you get pass that, that post should be deleted.

Talk Python's Mastodon Michael Kennedy's Mastodon