![]() ![]() Also, don’t begin your ID with the number 0. Use a unique ID and name that others aren’t likely to also use. ![]() Also, change the pet’s name of fluffy to something else. This information will be passed in the -d parameter of the curl request:Ĭhange the first id value to another integer (a whole number in this case). The list of JSON key-value pairs that the API accepts is called the “Model” in the Swagger UI display. Request bodies are often how you configure a service. Rather than trying to encode the JSON and pass it in the URL, you’ll store the JSON in a file and reference the file.Ī lot of APIs require you to post requests containing JSON messages in the body. To create a pet, you have to pass a JSON message in the request body. In this example, using the Petstore API, you’ll create a new pet, update the pet, get the pet’s ID, delete the pet, and then try to get the deleted pet. For now, we just need an API with which we can use to create, update, and delete content. However, we won’t actually use the Swagger UI (which is something we’ll explore later). Our sample weather API doesn’t allow you to use anything but a GET method, so for this exercise, to use other methods with curl, we’ll use the petstore API from Swagger.
0 Comments
Leave a Reply. |