diff --git a/amit_api b/amit_api new file mode 100644 index 0000000..0af7ec8 --- /dev/null +++ b/amit_api @@ -0,0 +1,247 @@ +{ + "info": { + "_postman_id": "ae80b739-3a26-4c32-8fba-f44639622c25", + "name": "API testing", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", + "_exporter_id": "29907652" + }, + "item": [ + { + "name": "New Request", + "request": { + "method": "GET", + "header": [] + }, + "response": [] + }, + { + "name": "New Request Copy", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n\r\n\"data\": {\r\n\r\n\"email\": \"amit@test.in\",\r\n\r\n\"first_name\": \"amit\",\r\n\r\n\"last_name\": \"pandey\"\r\n\r\n}\r\n\r\n}", + "options": { + "raw": { + "language": "text" + } + } + }, + "url": { + "raw": "https://reqres.in/api/users/", + "protocol": "https", + "host": [ + "reqres", + "in" + ], + "path": [ + "api", + "users", + "" + ] + } + }, + "response": [] + }, + { + "name": "Test Restponse Status Code", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + "\r", + "pm.response.to.have.status(200);\r", + "\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "https://reqres.in/api/user/13", + "protocol": "https", + "host": [ + "reqres", + "in" + ], + "path": [ + "api", + "user", + "13" + ] + } + }, + "response": [] + }, + { + "name": "Check JSON values", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Body matches string\", function () {\r", + "\r", + "pm.expect(pm.response.text()).to.include(\"Rachel\");\r", + "\r", + "});\r", + "\r", + "pm.test(\"Check JSON Data\", function () {\r", + "\r", + "var jsonData = pm.response.json();\r", + "\r", + "pm.expect(jsonData.data.id).to.eql(12);\r", + "\r", + "});\r", + "\r", + "pm.test(\"Check last name \", function () {\r", + "\r", + "var jsonData = pm.response.json();\r", + "\r", + "pm.expect(jsonData.data.last_name).to.eql(\"Howell\");\r", + "\r", + "});\r", + "\r", + "pm.test(\"Check url \", function () {\r", + "\r", + "var jsonData = pm.response.json();\r", + "\r", + "pm.expect(jsonData.support.url).contains(\"support-heading\");\r", + "\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "https://reqres.in/api/users/12", + "protocol": "https", + "host": [ + "reqres", + "in" + ], + "path": [ + "api", + "users", + "12" + ] + } + }, + "response": [] + }, + { + "name": "Full Body Match", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "var resp='{\"data\":{\"id\":2,\"email\":\"janet.weaver@reqres.in\",\"first_name\":\"Janet\",\"last_name\":\"Weaver\",\"avatar\":\"https://reqres.in/img/faces/2-image.jpg\"},\"support\":{\"url\":\"https://reqres.in/#support-heading\",\"text\":\"To keep ReqRes free, contributions towards server costs are appreciated!\"}}'\r", + "\r", + "pm.test(\"Body is correct\", function () {\r", + "\r", + "pm.response.to.have.body(resp);\r", + "\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "https://reqres.in/api/users/2", + "protocol": "https", + "host": [ + "reqres", + "in" + ], + "path": [ + "api", + "users", + "2" + ] + } + }, + "response": [] + }, + { + "name": "Test Post Req", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Successful POST request\", function () {\r", + "\r", + "pm.expect(pm.response.code).to.be.oneOf([201, 202]);\r", + "\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n\r\n\"name\": \"checking 2\",\r\n\r\n\"job\": \"leader\"\r\n\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "https://reqres.in/api/users", + "protocol": "https", + "host": [ + "reqres", + "in" + ], + "path": [ + "api", + "users" + ] + } + }, + "response": [] + }, + { + "name": "New Request", + "request": { + "method": "DELETE", + "header": [], + "url": { + "raw": "https://reqres.in/api/users/3", + "protocol": "https", + "host": [ + "reqres", + "in" + ], + "path": [ + "api", + "users", + "3" + ] + } + }, + "response": [] + } + ] +}