{"id":579,"date":"2024-06-16T07:28:20","date_gmt":"2024-06-16T07:28:20","guid":{"rendered":"https:\/\/istqblearning.com\/testing\/?page_id=579"},"modified":"2024-06-17T11:55:18","modified_gmt":"2024-06-17T11:55:18","slug":"run-crud-from-postman-curl","status":"publish","type":"page","link":"https:\/\/istqblearning.com\/testing\/run-crud-from-postman-curl\/","title":{"rendered":"Run CRUD from Postman, Curl"},"content":{"rendered":"\n<!DOCTYPE html>\n<html>\n<head>\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<style>\na:hover {\n  background-color: #ddd;\n  color: black;\n}\n\n.previous {\n  background-color: #f1f1f1;\n  color: black;\n}\n\n.previousnext {\n  text-decoration: none;\n  display: inline-block;\n  padding: 8px 16px;\n  background-color: #f1f1f1;\n  color: black;\n}\n<\/style>\n<\/head>\n<body>\n\n\n<a href=\"https:\/\/istqblearning.com\/testing\/install-and-configure-postman\/\" class=\"previousnext \">&laquo; Previous<\/a>\n<\/a>\n  \n<\/body>\n<\/html>\n\n\n\n<h2 class=\"wp-block-heading\">Import a Postman collection sample<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/Khong-co-tieu-de-6-1024x576.png\" alt=\"\" class=\"wp-image-670\" srcset=\"https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/Khong-co-tieu-de-6-1024x576.png 1024w, https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/Khong-co-tieu-de-6-300x169.png 300w, https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/Khong-co-tieu-de-6-768x432.png 768w, https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/Khong-co-tieu-de-6-1536x864.png 1536w, https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/Khong-co-tieu-de-6.png 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>We can download and import the sample below into your workspace in Postman.<\/p>\n\n\n\n<div class=\"wp-block-file\"><a id=\"wp-block-file--media-3e7f1de9-b129-4707-b1b5-e975b4d8f877\" href=\"https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/REST-API-basics-CRUD-test-variable.postman_collection.json\">REST API basics- CRUD, test &amp; variable.postman_collection<\/a><a href=\"https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/REST-API-basics-CRUD-test-variable.postman_collection.json\" class=\"wp-block-file__button wp-element-button\" download aria-describedby=\"wp-block-file--media-3e7f1de9-b129-4707-b1b5-e975b4d8f877\">Download<\/a><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Post REST API Url<\/h2>\n\n\n\n<p><a href=\"https:\/\/istqblearning.com\/wp-json\/wp\/v2\/posts\">https:\/\/istqblearning.com\/wp-json\/wp\/v2\/posts<\/a> is URL for the post REST API in the <a href=\"https:\/\/istqblearning.com\">https:\/\/istqblearning.com<\/a> website.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">GET method<\/h2>\n\n\n\n<h5 class=\"wp-block-heading\">Postman<\/h5>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/Khong-co-tieu-de-13-1024x576.png\" alt=\"\" class=\"wp-image-687\" srcset=\"https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/Khong-co-tieu-de-13-1024x576.png 1024w, https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/Khong-co-tieu-de-13-300x169.png 300w, https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/Khong-co-tieu-de-13-768x432.png 768w, https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/Khong-co-tieu-de-13-1536x864.png 1536w, https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/Khong-co-tieu-de-13.png 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>At the step 2, update value in textbox as &#8220;<code>{{base_url}}\/wp-json\/wp\/v2\/posts<\/code>&#8220;. It will get all posts in the website. We can request a post by adding post id after the url as image below.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/Khong-co-tieu-de-14-1024x576.png\" alt=\"\" class=\"wp-image-689\" srcset=\"https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/Khong-co-tieu-de-14-1024x576.png 1024w, https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/Khong-co-tieu-de-14-300x169.png 300w, https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/Khong-co-tieu-de-14-768x432.png 768w, https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/Khong-co-tieu-de-14-1536x864.png 1536w, https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/Khong-co-tieu-de-14.png 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h5 class=\"wp-block-heading\">Curl<\/h5>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/titled-01-11-1024x576.png\" alt=\"\" class=\"wp-image-605\" srcset=\"https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/titled-01-11-1024x576.png 1024w, https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/titled-01-11-300x169.png 300w, https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/titled-01-11-768x432.png 768w, https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/titled-01-11-1536x864.png 1536w, https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/titled-01-11.png 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Run GET method in Windows Command Prompt. <\/p>\n\n\n\n<p><code>curl -H \"Authorization:Basic dGVzdGVyOlRlc3QxMjM0NTY3OEA=\" https:\/\/istqblearning.com\/wp-json\/wp\/v2\/posts<\/code><\/p>\n\n\n\n<p>With &#8220;<code>dGVzdGVyOlRlc3QxMjM0NTY3OEA=<\/code>&#8221; is result of base64encoding from &#8220;<code>tester:Test12345678@<\/code>&#8220;. We can check the result from <a href=\"https:\/\/www.base64encode.org\/\">https:\/\/www.base64encode.org\/<\/a> url<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">POST method<\/h3>\n\n\n\n<h5 class=\"wp-block-heading\">Postman<\/h5>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/Khong-co-tieu-de-5-1024x576.png\" alt=\"\" class=\"wp-image-649\" srcset=\"https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/Khong-co-tieu-de-5-1024x576.png 1024w, https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/Khong-co-tieu-de-5-300x169.png 300w, https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/Khong-co-tieu-de-5-768x432.png 768w, https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/Khong-co-tieu-de-5-1536x864.png 1536w, https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/Khong-co-tieu-de-5.png 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>At the step 4, we add two key-value pairs as <code>title=Create a sample post by REST API POST method with basic authentication method - from Postman and status=publish<\/code>. After send the PUT request, the post will be created in the website. We can check it by refreshing the <a href=\"https:\/\/istqblearning.com\">https:\/\/istqblearning.com<\/a>. It will display in the homepage of the website.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Curl<\/h5>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/titled-01-13-1024x576.png\" alt=\"\" class=\"wp-image-616\" srcset=\"https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/titled-01-13-1024x576.png 1024w, https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/titled-01-13-300x169.png 300w, https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/titled-01-13-768x432.png 768w, https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/titled-01-13-1536x864.png 1536w, https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/titled-01-13.png 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Run PUT method in Windows Command Prompt.<\/p>\n\n\n\n<p><code>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&amp;status=publish<\/code>&#8220;<\/p>\n\n\n\n<p>We can check this creation by refreshing the <a href=\"https:\/\/istqblearning.com\">https:\/\/istqblearning.com<\/a>. It will display in the homepage of the website.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">PUT method<\/h3>\n\n\n\n<h5 class=\"wp-block-heading\">Postman<\/h5>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/Khong-co-tieu-de-15-1024x576.png\" alt=\"\" class=\"wp-image-691\" srcset=\"https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/Khong-co-tieu-de-15-1024x576.png 1024w, https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/Khong-co-tieu-de-15-300x169.png 300w, https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/Khong-co-tieu-de-15-768x432.png 768w, https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/Khong-co-tieu-de-15-1536x864.png 1536w, https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/Khong-co-tieu-de-15.png 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Update the id variable of a post which has been created from Postman or Curl with the account tester.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/Khong-co-tieu-de-18-1024x576.png\" alt=\"\" class=\"wp-image-705\" srcset=\"https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/Khong-co-tieu-de-18-1024x576.png 1024w, https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/Khong-co-tieu-de-18-300x169.png 300w, https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/Khong-co-tieu-de-18-768x432.png 768w, https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/Khong-co-tieu-de-18-1536x864.png 1536w, https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/Khong-co-tieu-de-18.png 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Configure the PUT method as the image above.<\/p>\n\n\n\n<p>At the step 4, we update title of the post as format below:<\/p>\n\n\n\n<p><code>{ \"title\": \"Update a sample post by REST API POST method with basic authentication method \u2013 from Postman\"}<\/code><\/p>\n\n\n\n<p>We can check updating by refreshing the <a href=\"https:\/\/istqblearning.com\">https:\/\/istqblearning.com<\/a>. It will display in the homepage of the website.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Curl<\/h5>\n\n\n\n<p>Run POST method in Windows Command Prompt.<\/p>\n\n\n\n<p><code>curl -H \"Authorization:Basic dGVzdGVyOlRlc3QxMjM0NTY3OEA=\" -X PUT https:\/\/istqblearning.com\/wp-json\/wp\/v2\/posts\/<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">&lt;id&gt;<\/mark> -d \"title=Update a sample post by REST API PUT method with basic authentication method - from Curl application\"<\/code><\/p>\n\n\n\n<p><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">&lt;id&gt;: <\/mark>Remember updating the id with an id of a post existing in the <a href=\"https:\/\/istqblearning.com\">https:\/\/istqblearning.com<\/a> website.<\/p>\n\n\n\n<p>We can check this creation by refreshing the <a href=\"https:\/\/istqblearning.com\">https:\/\/istqblearning.com<\/a>. It will display in the homepage of the website.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">DELETE method<\/h3>\n\n\n\n<h5 class=\"wp-block-heading\">Postman<\/h5>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/Khong-co-tieu-de-17-1024x576.png\" alt=\"\" class=\"wp-image-698\" srcset=\"https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/Khong-co-tieu-de-17-1024x576.png 1024w, https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/Khong-co-tieu-de-17-300x169.png 300w, https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/Khong-co-tieu-de-17-768x432.png 768w, https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/Khong-co-tieu-de-17-1536x864.png 1536w, https:\/\/istqblearning.com\/testing\/wp-content\/uploads\/2024\/06\/Khong-co-tieu-de-17.png 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Configure the DELETE method as the image above. After sending the DELETE request, the post will be deleted in the <a href=\"https:\/\/istqblearnig.com\">https:\/\/istqblearnig.com<\/a> website. We can check updating by refreshing the <a href=\"https:\/\/istqblearning.com\">https:\/\/istqblearning.com<\/a>. It will display in the homepage of the website.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Curl<\/h5>\n\n\n\n<p>Run DELETE method in Windows Command Prompt.<\/p>\n\n\n\n<p><code>curl -H \"Authorization:Basic dGVzdGVyOlRlc3QxMjM0NTY3OEA=\" -X DELETE https:\/\/istqblearning.com\/wp-json\/wp\/v2\/posts\/<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">&lt;id><\/mark><\/code><\/p>\n\n\n\n<p><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">&lt;id>: <\/mark>Remember updating the id with an id of a post existing in the <a href=\"https:\/\/istqblearning.com\">https:\/\/istqblearning.com<\/a> website.<\/p>\n\n\n\n<!DOCTYPE html>\n<html>\n<head>\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<style>\na:hover {\n  background-color: #ddd;\n  color: black;\n}\n\n.previous {\n  background-color: #f1f1f1;\n  color: black;\n}\n\n.previousnext {\n  text-decoration: none;\n  display: inline-block;\n  padding: 8px 16px;\n  background-color: #f1f1f1;\n  color: black;\n}\n<\/style>\n<\/head>\n<body>\n\n\n<a href=\"https:\/\/istqblearning.com\/testing\/install-and-configure-postman\/\" class=\"previousnext \">&laquo; Previous<\/a>\n<\/a>\n  \n<\/body>\n<\/html>\n","protected":false},"excerpt":{"rendered":"<p>&laquo; Previous 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 &#8220;{{base_url}}\/wp-json\/wp\/v2\/posts&#8220;. It will get all posts in [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-579","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/istqblearning.com\/testing\/wp-json\/wp\/v2\/pages\/579","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/istqblearning.com\/testing\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/istqblearning.com\/testing\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/istqblearning.com\/testing\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/istqblearning.com\/testing\/wp-json\/wp\/v2\/comments?post=579"}],"version-history":[{"count":50,"href":"https:\/\/istqblearning.com\/testing\/wp-json\/wp\/v2\/pages\/579\/revisions"}],"predecessor-version":[{"id":707,"href":"https:\/\/istqblearning.com\/testing\/wp-json\/wp\/v2\/pages\/579\/revisions\/707"}],"wp:attachment":[{"href":"https:\/\/istqblearning.com\/testing\/wp-json\/wp\/v2\/media?parent=579"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}