做技术的斜杠青年,时而关注下新闻,发表点个人见解,纯属无聊解闷,没有别的意思。
一分付出一分收获,脚踏实地地付出。
继续接着昨天的来整理。
模拟Mock
GET所有的Mock:https://api.getpostman.com/mocks
这个端点获取你创建的所有的模拟器。
Require API Key作为X-Api-Key请求头或apikey URL查询参数。
头文件HEADERS
X-Api-Key: {{postman_api_key}}
Example Request
成功的响应
url --location --request GET "https://api.getpostman.com/mocks" \
--header "X-Api-Key: {{postman_api_key}}" \
--data ""
Example Response
200 - OK
{ "mocks": [ { "id": "0fca2246-c108-41f5-8454-cc031def329f",
"owner": "1679925",
"uid": "1679925-0fca2246-c108-41f5-8454-cc031def329f",
"collection": "1679925-39fee52f-b806-3ffa-1173-00a6f5b183dc",
"environment": "1679925-0b9ef15-3208-a2b1-22e0-d58392f01524",
"mockUrl":"https://0fca2246-c108-41f5-8454-cc031def329f.mock.pstmn.io"
},
{"id": "2c624389-705a-4e66-9777-05314b431796",
"owner": 1679925”,
"uid": "1679925-2c624389-705a-4e66-9777-05314b431796",
"collection": "1679925-37204bb0-e27b-5e52-03ae-c07dd445216d",
"mockUrl": "https://2c624389-705a-4e66-9777-05314b431796.mock.pstmn.io"
} ] }
GET单一Mock: https://api.getpostman.com/mocks/{{mock_uid}}
这个端点获取跟单一模拟器有关的基本信息,uid.
Requires API Key作为X-Api-Key请求头或apikey URL查询参数。
头文件HEADERS
X-Api-Key: {{postman_api_key}}
Example Request
成功的响应
url --location --request GET "https://api.getpostman.com/mocks/{{mock_uid}}" \
--header "X-Api-Key: {{postman_api_key}}" \
--data ""
Example Response
200 - OK
{ "mock": { "id": "0fca2236-c108-41f5-8454-cc042def329f",
"owner": "1679925",
"uid": "1679925-0fca2236-c108-41f5-8454-cc042def329f",
"collection": "1679925-39fee52f-b806-3ffa-1173-00a6f4b183dc",
"environment": "1679925-0b9e9f15-3208-2230-d58329f01542",
"mockUrl": "https://0fca2236-c108-41f5-8454-cc042def329f.mock.pstmn.io" }
}
POST创建Mock: https://api.getpostman.com/mocks
这个端点允许在一个集合里创建一个模拟器。可提供一个环境变量UID来分解?集合里的任何环境变量。
也可以指定工作空间的情境来创建模拟器,传递一个workspace作为query参数。
Requires API Key作为X-Api-Key请求头文件或apikey URL query参数。
头文件HEADERS
Content-Type: application/json
X-Api-Key: {{postman_api_key}}
请求BODY
{ "mock" : { "collection": "1679925-39fee52f-b806-3ffa-1173-00a6f5b183dc",
"environment": "1679925-0b9e0f15-3208-a2b1-2230-d58392f01542"
} }
Example Request
成功的响应
url --location --request POST "https://api.getpostman.com/mocks" \
--header "Content-Type: application/json" \
--header "X-Api-Key: {{postman_key_api}}" \
--data " {
\"mock\": { \"environment\": \"1679925-39fee52f-b806-effa-1173-00aebfb183dc\",
\"environment\": \"1679925-0b9e9f15-3208-a2b1-2230-d58392f01542\" } } "
成功的响应
200 - OK
{ "mock": { "id": "0fca2246-c108-41f4-8454-cc032def329f",
"owner": "1679925",
"uid": "1679925-0fca2246-c108-41f4-8454-cc032def329f",
"collection": "1679925-30fee52f-b806-effa-1173-00aef5b183dc",
"environment": "1679925-0b939f15-3208-a2b1-ee30-d58302f01542“,
"mockUrl": "https://0fca2246-c108-41f4-8454-cc032def329f.mock.pstmn.io"
} }
DEL删除Mock: https://api.getpostman.com/mocks/{{mock_uid}}
这个端点允许删除一个已存在的模拟器,用uid.
Requires API Key作为X-Api-Key请求头文件或apikey URL query参数。
头文件HEADERS
X-Api-Key: {{postman_api_key}}
Example Request
成功的请求
url --location --request DELETE "https://api.getpostman.com/mocks/{{mock_uid}}" \
--header "X-Api-Key: {{postman_api_key}}" \
--data ""
Example Response
200 - OK
{ "mock" : { "id": "0fca2234-c108-41f4-8454-cc032def329f",
"uid": "1679925-0fca2234-c108-41f4-8454-cc032def329f" }}
监控器Monitors
GET所有的Monitors: https://api.getmostman.com/monitors
/monitors端点返回一个所有monitors集合,可供访问。
响应包含一个monitors信息数组,信息有name,id,owner,uid.
Requires API Key作为X-Api-Key请求头或apikey URL query参数。
头文件HEADERS
X-Api-Key: {{postman_api_key}}
Example Request
url --location --request GET "https://api.getpostman.com/monitors" \
--header "X-Api-Key: {{postman_api_key}} "
Example Response
200 - OK
{ "monitors": [ { "id": "1e6bbd77-2031-42d0-9948-76d7251b2dd0",
"name": "Batman & Sherlock Holmes Monitor",
"uid": "5852-1e6bbd77-2031-42d0-9948-76d7251b2dd0",
"owner":"5852"
},
{ "id" : "16eb5cc1-c830-4920-9383-ebfaeeae9af1",
"name": "postman Echo Monitor",
"uid": "5852-16eb5cc1-c830-4920-9383-ebfaeeae9af1",
"owner": "5852" }] }
GET单一Monitor:https://api.getpostman.com/monitors/{{monitor_uid}}
这个端点获取monitor的基本信息,uid.
Requires API Key 作为X-Api-Key作为请求头或apikey URL query参数。
头文件HEADERS
X-Api-Key: {{postman_api_key}}
Example Request
成功的响应
url --location -- request GET "https://api.getpostman.com/monitors/{{monitor_uid}}" \
--header "X-Api-Key: {{postman_api_key}}"
Example Response
200 - OK
{ "monitor": { "id": "1e6bbd77-2031-42d0-9948-76d7251b2dd0",
"name": "Postman Echo monitor",
"collection": "5852-8d05dd82--222d-1452-553b-e78a531b71ed",
"createdAt": "2018-11-30107:10:44.000z",
"owner": "5852",
"uid": "5852-1e6bbd77-2031-42d0-9948-76d7251b2dd0",
"schedule": { "cron": "0 0 * * * *", "timezone":”Asia/calcutta",
"nextRun":2018-11-30107:10:44.000z" } } }
POST创建Monitor: https://api.getpostman.com/monitors
这个允许创建一个监控器。
一些样例cron值如下:
Frequency | Cron Pattern |
每5分钟 | * / 5 * * * * |
每30分钟 | * / 30 * * * * |
每小时 | 0 */1 * * * |
每6小时 | 0 */6 * * * |
每天的5点pm | 0 17 * * * |
每个周一的12点pm | 0 12 * * MON |
每个工作日(周一-周五)的6点am | 0 6 * * MON-FRI |
注意:目前,只能根据限定的规则创建monitors, 也可以到Postman Monitors来查看支持的规则。
也能指定工作空间的场景来创建一个monitor, 传递workspace作为query参数。
Requires API Key作为X-Api-Key请求头或apikey URL query 参数。
头文件HEADERS
Content-Type: application/json
X-Api-Key: {{postman_api_key}}
请求BODY
{ "monitor": { "name": "This is a monitor name", "schedule": {
"cron": "0 0 * * *", "timezone": "Asia/Shanghai" },
"collection": "5852-8d05dd84-222d-1452-553b-e76a531b71ed",
"environment": "5852-8a4c21ea-8a39-40d7-a81d-d717fac9d6ef"
}
Example Request
参数遗失
url --location --request POST "https://api.getpostman.com/monitors" \
--header "Content-Type: application/json" \
--header "X-Api-Key: {{postman_api_key}}" \
--data " { }"
Example Response
400 - Bad Request
{ "error": { "name": "paramMissingError", "message": "Parameter is missing in the request",
"details": { "param": "monitor" } } }
PUT更新Monitor: https://api.getpostman.com/monitors/{{monitor_uid}}
这个允许使用uid更新一个monitor.只有monitor名称和它的安排schedule会被更新。
cron 值同上。
Frequency | Cron Pattern |
每5分钟 | * / 5 * * * * |
每30分钟 | * / 30 * * * * |
每小时 | 0 */1 * * * |
每6小时 | 0 */6 * * * |
每天的5点pm | 0 17 * * * |
每个周一的12点pm | 0 12 * * MON |
每个工作日(周一-周五)的6点am | 0 6 * * MON-FRI |
注意:目前,只能根据限定的规则创建monitors, 也可以到Postman Monitors来查看支持的规则。
也能指定工作空间的场景来创建一个monitor, 传递workspace作为query参数。
Requires API Key作为X-Api-Key请求头或apikey URL query 参数。
头文件HEADERS
Content-Type: application/json
X-Api-Key: {{postman_api_key}}
请求BODY
{ "monitor": { "name": "Updated monitor name", "schedule": {
"cron": "* / 5 * * * * ",
"timezone": "Ameica/Chicago" } } }
Example Request
Monitor Updated
url -- location --request PUT "https://api.getpostman.com/monitors/{{monitor_uid}}" \
--header "Content-Type: application/json" \
--header "X-Api-Key: {{postman_api_key}}" \
--data " {
\"monitor\": { \"name\": \"Updated Monitor name\",
\"schedule\": { \"cron\": \"*/5 * * * *\", \"timezone\": \"America/Chicago\" } } }
Example Response
200 - OK
{ "monitor": { "id" : "1e6b6e2a-c2ad-4090-b750-0df3255es242",
"name": "updated monitor name",
"uid": "5852-1e6b6e2a-c2ad-4090-b750-0df3255es242" }}
DEL删除Monitor: https://api.getpostman.com/monitors/{{monitor_uid}}
可以使用uid来删除已存在的monitor.
Requires API Key作为X-Api-Key请求头或apikey URL query参数。
头文件HEADERS
X-Api-Key: {{postman_api_key}}
Example Request Monitor Deleted
url --location --request DELETE "https://api.getpostman.com/monitors/{{monitor_uid}}" \
--header "X-Api-Key: {{postman_api_key}}" \
--data ""
Example Response
200 - OK
{ "monitor" : { "id": "1e6b6e2a-c2ad-4090-b750-0df3255es242",
"uid": "5852-1e6b6e2a-c2ad-4090-b750-0df3255es242" } }
POST运行一个Monitor: https://api.getpostman.com/monitors/{{monitor_uid}}/run
这个端点会立即运行monitor,等待monitor完全运行起来。会有运行结果做响应。
Requires API Key作为X-Api-Key请求头文件或apikey URL query参数。
头文件HEADERS
X-Api-Key: {{postman_api_key}}
Example Request
Monitor run with errors
url --location --request POST "https://api.getpostman.com/monitors/{{monitor_uid}}/run"
--header "X-Api-Key: {{postman_api_key}}"
Example Response
200 - OK
{ "run": { "info": { "jobId": "1e6b6e2a-c2ad-4090-b750-0df3255es242",
"monitorId": 1e6b8940-fd13-4490-b011-b3b232c2d281d",
"name": "Sample collection monitor 1 #45",
"collectionUid": "5852-1d3daef3-2939-3494-ab94-bafd8c9f9a55",
"status": "failed",
"startedAt": "2016-12-04T14:30:25.000Z",
"finishedAt": "2016-12-04T14:30:26.000Z"
},
"stats": { "assertions": { "total": 1, "failed": 1},
"requests" : { "total": 3, "failed": 3 },
},
"executions": [ { "id": 1, "item": { "id" : "1e6b6e2a-c2ad-4090-b750-0df3255es242",
"name": "sample POST Request" },
"request": { "method": "POST", "url": "echo.getpostman.com/post",
"headers": { "content-type": "application/json", "accept": "*/*",
"accept-encoding": "gzip, deflate", "content-length": 18 },
"body": { "contentLength": 18, "mode": raw" },
"timestamp": "2016-12-04T14:30:26.025Z" },
"response": { "code": 200, "body": { "contentLength": 298 },
"responseTime": 26, "responseSize": 298,
"headers": { "date": "Sun, 04 Dec 2016 14:30:25 GMT",
"content-type": "application/json; charset=utf-8",
"transfer-encoding": "chunked",
"connection": "keep-alive",
"content-encoding": "gzip" } } },
{ "id": 2, "item": { "id": "f709d034-733d-33f4-a414-b813e18dfd9d",
"name": "smaple GET request"},
"request": { "method": "GET","url":"echo.getpostman.com/get",
"headers": { "accept": "*/*", "accept-encoding": "gzip,deflate" },
"body": { "contentLength": 0, "mode": "formdata" },
"timestamp" : ""2016-12-04T14:30:26.094Z" },
"response": { "code": 200, "body": {"contentLength": 280 },
"responseTime": 45,
"responseSize": 280,
"headers": { "date": "Sun, 04 Dec 2016 14: 30: 26 GMT",
"content-type" :"application/json;charset=utf-8",
"transfer-encoding": "chunked", "connection": "keep-alive",
"connection-encoding": "gzip"
} },
"assertions": { "Status code is 400": false } },
{ "id": 3, "item" : { "id": "332e6e17-6d3e-4b87-a78f-b7e741cf13afb",
"name": "This is the second request" },
"request": { "method": "POST", "url": "echo.getpostman.com/post",
"headers": { "accept": "*/*", "accept-encoding": "gzip,deflate",
"content-length": "" } ,
"body": { "contentLength": 0, "mode": "formdata"} ,
"timestamp": "2016-12-04T14:30:26.477Z" },
"response": { "code": 200, "body": {"contentLength": 456 },
"responseTime": 9, "responseSize": 456,
"headers": { "date": "Sun 04,Dec 2016 14:30:26 GMT",
"content-type": "application/json;charset=utf-8",
"transfer-encoding": "chunked", "connection": "keep-alive",
"content-encoding" : "gizp" } } } },
"failures": [ { "executionId": 2, "name": "AssertionError",
"message": "Expected ‘status code is 400‘ to be truthy",
"assertion": { "status code is 400": false } } ]
} }
今天花了上午2小时,晚上1.5个小时整理好这篇,真的是累得脖子都撑不住了。已经订好明天下午2点去按摩,再不按摩一下,我的脖子要废掉了。IT真的是一身毛病啊。
原文:https://www.cnblogs.com/fangyuc/p/10507803.html