@apica-io/asm-pm-runner
Version:
Run a postman collection in Apica ASM.
186 lines • 3.9 kB
JSON
{
"info": {
"_postman_id": "7121cfe1-3146-463d-8fe8-9a88b9a00b60",
"name": "JsonPlaceHolder-Get-UserInfo",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "GetUser",
"item": [
{
"name": "Get a random user",
"event": [
{
"listen": "test",
"script": {
"exec": [
"var jsonData = JSON.parse(responseBody);",
"var randomIdx = parseInt(Math.floor(Math.random() * jsonData.length))",
" var userId=jsonData[randomIdx].id",
"pm.collectionVariables.set(\"userId\", userId)"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{baseUrl}}/users",
"host": [
"{{baseUrl}}"
],
"path": [
"users"
]
}
},
"response": []
}
]
},
{
"name": "UpdatePost",
"item": [
{
"name": "Get a Random Post",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
"var postId = parseInt(Math.floor(Math.random() * 100)) +1",
"pm.collectionVariables.set(\"postId\", postId)",
""
],
"type": "text/javascript"
}
},
{
"listen": "test",
"script": {
"exec": [
"function replaceAll(string, search, replace) {",
" return string.split(search).join(replace);",
"}",
"var jsonData = JSON.parse(responseBody);",
"var title=jsonData.title",
"//var body=jsonData.body.replace(\"\\\\n\",\" \")",
"var body=replaceAll(jsonData.body,\"\\n\",\"0x0A\")",
"pm.collectionVariables.set(\"title\", title)",
"pm.collectionVariables.set(\"body\", body)"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{baseUrl}}/posts/{{postId}}",
"host": [
"{{baseUrl}}"
],
"path": [
"posts",
"{{postId}}"
]
}
},
"response": []
},
{
"name": "Update Post",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
"var postId = parseInt(Math.floor(Math.random() * 100)) +1",
"pm.collectionVariables.set(\"postId\", postId)",
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "PUT",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"userId\": \"{{userId}}\",\n \"title\": \"{{title}}\",\n \"body\": \"{{body}}\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/posts/{{postId}}",
"host": [
"{{baseUrl}}"
],
"path": [
"posts",
"{{postId}}"
]
}
},
"response": []
}
]
}
],
"event": [
{
"listen": "prerequest",
"script": {
"type": "text/javascript",
"exec": [
""
]
}
},
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"pm.test(\"HTTP Status OK\", function () {",
" pm.response.to.have.status(200);",
"});"
]
}
}
],
"variable": [
{
"key": "baseUrl",
"value": "https://jsonplaceholder.typicode.com"
},
{
"key": "userId",
"value": ""
},
{
"key": "postId",
"value": ""
},
{
"key": "body",
"value": ""
},
{
"key": "title",
"value": ""
},
{
"key": "body_var",
"value": ""
}
]
}