In Chapter 3, Creating API Views, when we composed and sent
PUT commands, we had to use the use the
-H "Content-Type: application/json" option to indicate curl to send the data specified after the
-d option as
application/json. We had to use this option because the default content-type in curl is
Now, our RESTful Web Service goes beyond JSON and it can also parse
multipart/form-data data specified in the
PUT requests. Hence, we can compose and send a
POST command that sends the data as
We will compose and send an HTTP request to create a new toy. In this case, we will use the
-f option for HTTP.
This option serializes data items from the command line as form fields and sets the
Content-Type header key to the
application/x-www-form-urlencoded value. Run the next command:
http -f POST :8000/toys/ name="Ken in Rome" description="Ken loves...