Skip to content

Commit a08dcc2

Browse files
committed
Enable requests to Smart 1 Cloud management service
1 parent 9708292 commit a08dcc2

File tree

1 file changed

+28
-13
lines changed

1 file changed

+28
-13
lines changed

common/cme_api_postman/CME_API.postman_collection

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9307,24 +9307,39 @@
93079307
"type": "text/javascript",
93089308
"exec": [
93099309
"pm.test(\"Check for collectionVariables\", function () {",
9310-
" let vars = ['managementIP', 'user', 'password'];",
9311-
" vars.forEach(function (item, index, array) {",
9312-
" console.log(item, index);",
9313-
" pm.expect(pm.collectionVariables.get(item), item + \" variable not set\").to.not.be.undefined;",
9314-
" pm.expect(pm.collectionVariables.get(item), item + \" variable not set\").to.not.be.empty; ",
9315-
" });",
9310+
" let managementIP = pm.collectionVariables.get(\"managementIP\");",
9311+
" let sessionId = pm.collectionVariables.get(\"sessionId\");",
9312+
" let user = pm.collectionVariables.get(\"user\");",
9313+
" let password = pm.collectionVariables.get(\"password\");",
9314+
" ",
9315+
" // Auto-detect S1C format: optimized detection and extraction",
9316+
" if (managementIP?.includes('/')) {",
9317+
" [managementIP, sessionId] = managementIP.split('/', 2);",
9318+
" pm.collectionVariables.set(\"sessionId\", sessionId);",
9319+
" }",
9320+
" ",
9321+
" pm.expect(managementIP, \"managementIP variable not set\").to.not.be.undefined;",
9322+
" pm.expect(managementIP, \"managementIP variable not set\").to.not.be.empty;",
9323+
" ",
9324+
" // Prepare login payload based on available credentials",
9325+
" let loginPayload = { 'session-id': sessionId };",
9326+
" ",
9327+
" if (!sessionId?.trim()) {",
9328+
" pm.expect(user, \"user variable not set\").to.not.be.undefined;",
9329+
" pm.expect(user, \"user variable not set\").to.not.be.empty;",
9330+
" pm.expect(password, \"password variable not set\").to.not.be.undefined;",
9331+
" pm.expect(password, \"password variable not set\").to.not.be.empty;",
9332+
" loginPayload = { user, password };",
9333+
" }",
93169334
"",
93179335
" if (!pm.collectionVariables.get(\"session\") || Date.now() > new Date(pm.collectionVariables.get(\"sessionTimeout\") * 1000)) {",
93189336
" pm.sendRequest({",
9319-
" url: 'https://' + pm.collectionVariables.get(\"managementIP\") + '/web_api/v1.8/login',",
9337+
" url: 'https://${managementip}/web_api/v1.8/login',",
93209338
" method: 'POST',",
9321-
" header: 'Content-Type: application/json', // Set the Content-Type header to application/json",
9339+
" header: 'Content-Type: application/json',",
93229340
" body: {",
9323-
" mode: 'raw', // Use raw body mode",
9324-
" raw: JSON.stringify({ // Convert the object to JSON string",
9325-
" user: pm.collectionVariables.get(\"user\"),",
9326-
" password: pm.collectionVariables.get(\"password\")",
9327-
" })",
9341+
" mode: 'raw',",
9342+
" raw: JSON.stringify(loginPayload)",
93289343
" }",
93299344
" }, function (err, res) {",
93309345
" if (err) {",

0 commit comments

Comments
 (0)