The Message Body
Making use of POST, PUT, and PATCH you need to send the data in the requests body. In this lesson you’ll learn how to do exactly that. Furthermore, it covers the differences between using the
data and the
json parameter to specify the payload.
PATCH pass data through what’s called the message body. It’s different from the query string parameters that we used before. The payload is passed through the parameter
data, and the
data can take inside of it a dictionary, a list of tuples, bytes, or file-like objects.
This time, it’s all about posting. Let’s try our data in a couple of different formats here and see what it looks like. Save it into a
Response, and as you can see, there’s a couple of ways you can send the data. We can send it in—in this case—in a dictionary or a tuple, or in the case of JSON, we said it like this. Let’s try our dictionary.
So, there we can see what our request returned back in our response, and we can see the data going in here. There’s a
'form'. Let’s talk about that a little bit more. So
json_response, and we’ll look at the header, and what is the
'Content-Type' in this case?
Okay. Close my list. And success. Let’s save this into a
json_response also, which you can see here. We can do the same trick. Let’s look at the
'Content-Type' this time… and it’s the same. And we can see that
'form' data here. In fact, let’s look at the
Become a Member to join the conversation.