Run CRUD from Postman, Curl
Import a Postman collection sample

We can download and import the sample below into your workspace in Postman.
Post REST API Url
https://istqblearning.com/wp-json/wp/v2/posts is URL for the post REST API in the https://istqblearning.com website.
GET method
Postman

At the step 2, update value in textbox as “{{base_url}}/wp-json/wp/v2/posts
“. It will get all posts in the website. We can request a post by adding post id after the url as image below.

Curl

Run GET method in Windows Command Prompt.
curl -H "Authorization:Basic dGVzdGVyOlRlc3QxMjM0NTY3OEA=" https://istqblearning.com/wp-json/wp/v2/posts
With “dGVzdGVyOlRlc3QxMjM0NTY3OEA=
” is result of base64encoding from “tester:Test12345678@
“. We can check the result from https://www.base64encode.org/ url
POST method
Postman

At the step 4, we add two key-value pairs as title=Create a sample post by REST API POST method with basic authentication method - from Postman and status=publish
. After send the PUT request, the post will be created in the website. We can check it by refreshing the https://istqblearning.com. It will display in the homepage of the website.
Curl

Run PUT method in Windows Command Prompt.
curl -H "Authorization:Basic dGVzdGVyOlRlc3QxMjM0NTY3OEA=" -X POST https://istqblearning.com/wp-json/wp/v2/posts -d "title=Create a sample post by REST API POST method with basic authentication method - from Curl application&status=publish
“
We can check this creation by refreshing the https://istqblearning.com. It will display in the homepage of the website.
PUT method
Postman

Update the id variable of a post which has been created from Postman or Curl with the account tester.

Configure the PUT method as the image above.
At the step 4, we update title of the post as format below:
{ "title": "Update a sample post by REST API POST method with basic authentication method – from Postman"}
We can check updating by refreshing the https://istqblearning.com. It will display in the homepage of the website.
Curl
Run POST method in Windows Command Prompt.
curl -H "Authorization:Basic dGVzdGVyOlRlc3QxMjM0NTY3OEA=" -X PUT https://istqblearning.com/wp-json/wp/v2/posts/<id> -d "title=Update a sample post by REST API PUT method with basic authentication method - from Curl application"
<id>: Remember updating the id with an id of a post existing in the https://istqblearning.com website.
We can check this creation by refreshing the https://istqblearning.com. It will display in the homepage of the website.
DELETE method
Postman

Configure the DELETE method as the image above. After sending the DELETE request, the post will be deleted in the https://istqblearnig.com website. We can check updating by refreshing the https://istqblearning.com. It will display in the homepage of the website.
Curl
Run DELETE method in Windows Command Prompt.
curl -H "Authorization:Basic dGVzdGVyOlRlc3QxMjM0NTY3OEA=" -X DELETE https://istqblearning.com/wp-json/wp/v2/posts/<id>
<id>: Remember updating the id with an id of a post existing in the https://istqblearning.com website.
« Previous