In this post we are going to perform a crud operation using a simple items Api's. CRUD represents Create, Read update/Edit and Delete Data which are fundamental operations of any information system, However for Api's this is achieved by use of the following HTTP methods which are GET,POST,PUT,DELETE etc as they are explained as below:
GET/ READ
API end point https://items-api.kwikirizadan.repl.co/items
For a Get request you just need an API end point like the one listed above. However some times the API end points may have parameters
open postman and generate a new GET request then paste the end point and hint send and the data will be shown in json format in the body Tab
POST /CREAT
API end point https://items-api.kwikirizadan.repl.co/item
in postman past the link alongside the the http method and make sure the Method is POST.
Choose body tab and select raw then click from text to json
The write information in a json form like the lype below, remember The item has id but don't bother they are auto increased
{
"name":"New Item",
"desc":"New Item describtion"
}
hint send
PUT /UPDATE
API END POINT
https://items-api.kwikirizadan.repl.co/item/10
(10 presents the Id of the Item to be edited feel free to use any number)
For the put method we need an item id which should be edited then in the body section we select the the data to be changed on a specific ID
Just like the POST Method you need to insert the data in the body Tab then Raw and should be in json format
{
"name":"New Item edited",
"desc":"New Item describtion edited"
}
DELETE
API END POINT
https://items-api.kwikirizadan.repl.co/item/10
(10 presents the Id of the Item to be deleted feel free to use any number)
For the Delete method we need an item id which should be Deleted passed in the API endpoint then the Method to be Delete and click send
GET SINGLE ITEM
API END POINT
https://items-api.kwikirizadan.repl.co/item/10
(10 presents the Id of the Item to be retrieve feel free to use any number)
For the GET method we need an item id which should be retrieved passed in the API endpoint then the Method to be GET and click send
Top comments (0)