Resolve current Matrix42 user ID in Postman collection
This commit is contained in:
@@ -171,6 +171,53 @@
|
||||
}
|
||||
],
|
||||
"item": [
|
||||
{
|
||||
"name": "00 User context",
|
||||
"item": [
|
||||
{
|
||||
"name": "get current user ID",
|
||||
"event": [
|
||||
{
|
||||
"listen": "test",
|
||||
"script": {
|
||||
"type": "text/javascript",
|
||||
"exec": [
|
||||
"const currentUser = pm.response.json();",
|
||||
"const currentUserId = currentUser && currentUser.Id;",
|
||||
"",
|
||||
"pm.test(\"Current Matrix42 user ID is available\", function () {",
|
||||
" pm.expect(currentUserId).to.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i);",
|
||||
"});",
|
||||
"",
|
||||
"if (currentUserId) {",
|
||||
" pm.collectionVariables.set(\"userId\", currentUserId);",
|
||||
"}"
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"header": [
|
||||
{
|
||||
"key": "Accept",
|
||||
"value": "application/json"
|
||||
}
|
||||
],
|
||||
"url": {
|
||||
"raw": "{{baseUrl}}/api/userinfo",
|
||||
"host": [
|
||||
"{{baseUrl}}"
|
||||
],
|
||||
"path": [
|
||||
"api",
|
||||
"userinfo"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "01 Health and diagnostics",
|
||||
"item": [
|
||||
|
||||
Reference in New Issue
Block a user