Resolve current Matrix42 user ID in Postman collection

This commit is contained in:
Drechsler, Meik
2026-07-23 19:13:08 +02:00
parent c85addf0f4
commit 9322376b22

View File

@@ -171,6 +171,53 @@
} }
], ],
"item": [ "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", "name": "01 Health and diagnostics",
"item": [ "item": [