Created
June 22, 2021 11:45
-
-
Save thomd/67dc426d8a1212fc5795b5c06d3db156 to your computer and use it in GitHub Desktop.
postman example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"info": { | |
"_postman_id": "a3392caa-14c3-4415-a1cd-42cf3492c313", | |
"name": "httpbin", | |
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" | |
}, | |
"item": [ | |
{ | |
"name": "ip", | |
"event": [ | |
{ | |
"listen": "test", | |
"script": { | |
"exec": [ | |
"pm.test(\"Status code is 200\", () => {", | |
" pm.expect(pm.response.code).to.eql(200)", | |
"})", | |
"", | |
"pm.test(\"JSON Response contains an IP\", () => {", | |
" pm.expect(pm.response.json().origin).to.match(/\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}/)", | |
"})", | |
"" | |
], | |
"type": "text/javascript" | |
} | |
} | |
], | |
"request": { | |
"method": "GET", | |
"header": [], | |
"url": { | |
"raw": "http://httpbin.org/ip", | |
"protocol": "http", | |
"host": [ | |
"httpbin", | |
"org" | |
], | |
"path": [ | |
"ip" | |
] | |
} | |
}, | |
"response": [] | |
}, | |
{ | |
"name": "get", | |
"event": [ | |
{ | |
"listen": "test", | |
"script": { | |
"exec": [ | |
"pm.test(\"Status code is 200\", () => {", | |
" pm.expect(pm.response.code).to.eql(200)", | |
"})", | |
"", | |
"pm.test(\"JSON Response contains get parameter\", () => {", | |
" var name = pm.environment.get('name')", | |
" pm.expect(pm.response.json().args.name).to.be.equal(name)", | |
"})", | |
"" | |
], | |
"type": "text/javascript" | |
} | |
}, | |
{ | |
"listen": "prerequest", | |
"script": { | |
"exec": [ | |
"if(!pm.environment.get('name')) {", | |
" pm.environment.set('name', 'Hello World')", | |
"}", | |
"" | |
], | |
"type": "text/javascript" | |
} | |
} | |
], | |
"request": { | |
"method": "GET", | |
"header": [], | |
"url": { | |
"raw": "http://httpbin.org/get?name={{name}}", | |
"protocol": "http", | |
"host": [ | |
"httpbin", | |
"org" | |
], | |
"path": [ | |
"get" | |
], | |
"query": [ | |
{ | |
"key": "name", | |
"value": "{{name}}" | |
} | |
] | |
} | |
}, | |
"response": [] | |
} | |
] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"id": "6e662e8a-5ba4-4ac1-a459-c4c342c88a7b", | |
"name": "httpbin", | |
"values": [ | |
{ | |
"key": "name", | |
"value": "Hello Env", | |
"enabled": true | |
} | |
], | |
"_postman_variable_scope": "environment", | |
"_postman_exported_at": "2021-06-22T11:38:21.350Z", | |
"_postman_exported_using": "Postman/8.6.2" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment