Modern APIs with FastAPI and Python Transcripts
Chapter: Accepting inbound data
Lecture: Calling the POST method with RESTful tools

Login or purchase this course to watch this video and the rest of the course contents.
0:00 While our browser will let us do get requests really easily, over here, doing a post, while possible with some browser
0:08 addon tools and whatnot, is not the best place to be doing that kind of stuff. So let's go over here to a tool called Postman.
0:14 Postman is a freemium app you can check out and it lets you do all sorts of interesting requests. Like here we go like this.
0:21 Let's get something back, like "weather slash portland" and run it. Here you can see our report showing up down there,
0:27 right? But what we want to do is submit some data. Look at all these http verbs. We're gonna do a post and in order to do a post, well,
0:35 we could send some stuff over. It's gonna say we're missing stuff. What are we missing? Just the body.
0:41 There's nobody submitted. Come over to the body and say this is raw JSON, make this a little bit bigger.
0:48 And I happened to leave, I didn't leave that tap open. Too bad. Let's go and generate it real quickly just to get an example here.
0:56 Let's go put this back. This will tell us what goes here, and look at the raw data. We got to submit one of those, basically. Put it back.
1:04 Alright, So what we're gonna do is we're going to submit basically this right here. But remember, we could put a better description.
1:10 We could omit the state. We could omit the country, if we wanted. ID We're not going to submit, the created date we're not going to submit. Okay,
1:18 so the description is there is heavy rain, and this will be Portland. Let's go for the state is gonna be Oregon, just
1:27 to be explicit. Now, if we submit that body, we might not have this missing field. Let's go. Yes. Look at that. What did we get back? Well,
1:36 first of all, we got a 200 ok. That's not perfect, but that's a good sign. And then it says there's heavy rain. Here's the location. And it look,
1:44 it created an ID and set the date, so it saved it to the database. And how do we know? We can come over here and do a get against that URL. get, get,
1:53 get, and look. Here it is. Let's submit one more thing. Because there was that heavy rain, we saw a little bit of flooding,
2:00 so we send that again. Now if I do a get request against this and
2:05 see, here's the little flooding and there's heavy rain and again the sorting is working great. How cool is that? So here's how we can go and do a post
2:15 and all the http verbs and really nicely work with our API and test it out.

Talk Python's Mastodon Michael Kennedy's Mastodon