{"id":"6f8223d4-497c-4d0f-8df4-b7a92ac208b5","name":"Msaas API","description":null,"auth":null,"events":null,"variables":null,"order":["13a2482e-1d01-4b04-8c48-ac4b1dbe68c0"],"folders_order":["3d1eadea-4a32-47ee-b8d9-24545112f994","db2fe451-be2a-4a07-ba09-f24803f35e4e","e038790f-be90-446b-9355-f1218ec51615"],"folders":[{"id":"e038790f-be90-446b-9355-f1218ec51615","name":"Demo","description":"Common partner scenarios run together as bundle via Postman Runner.","auth":null,"events":null,"collection":"6f8223d4-497c-4d0f-8df4-b7a92ac208b5","folder":null,"order":[],"folders_order":[],"collectionId":"6f8223d4-497c-4d0f-8df4-b7a92ac208b5","folderId":"e038790f-be90-446b-9355-f1218ec51615"},{"id":"db2fe451-be2a-4a07-ba09-f24803f35e4e","name":"Microsoft Scenarios","description":"The requests only granted to the Microsoft agents.","auth":null,"events":[{"listen":"prerequest","script":{"id":"0bb2f440-7c90-4571-87c7-753c6687a252","type":"text\/javascript","exec":["eval(pm.globals.get(\"validateAndUpdateToken\"))(false); \/\/ compile and execute validateAndUpdateToken() to validate token and get new token if current one is absent or expired"]}},{"listen":"test","script":{"id":"af790b0c-ccad-4db4-bbc6-54bb7f749024","type":"text\/javascript","exec":[""]}}],"collection":"6f8223d4-497c-4d0f-8df4-b7a92ac208b5","folder":null,"order":["be3937b5-7640-4e0c-a5a6-aeafe65d7f71"],"folders_order":[],"collectionId":"6f8223d4-497c-4d0f-8df4-b7a92ac208b5","folderId":"db2fe451-be2a-4a07-ba09-f24803f35e4e"},{"id":"3d1eadea-4a32-47ee-b8d9-24545112f994","name":"Partner Scenarios","description":"Common requests the partners utilize.","auth":{"type":"noauth"},"events":[{"listen":"prerequest","script":{"id":"5cb57e54-1609-4788-95c8-9a306d776614","type":"text\/javascript","exec":["\/\/ Proactively validate and update access token if needed prior to request","eval(pm.globals.get(\"validateAndUpdateToken\"))(false); \/\/ compile and execute validateAndUpdateToken() to validate token and get new token if current one is absent or expired. Note that \"false\" means it does NOT forcibly\/unconditionally request for new access token, but makes validation on the existing token first."]}},{"listen":"test","script":{"id":"443255f2-01eb-4488-b8d3-1b1e62841d47","type":"text\/javascript","exec":["\/\/ \"Not Authorized\" scenario request failure handling","if (pm.response.code == 401) {","    eval(pm.globals.get(\"validateAndUpdateToken\"))(true); \/\/ Forcibly\/Unconditionally (hence \"true\" as argument) request a new token regardless if one is present.","    console.log(\"Access Token is being updated. Please try again the originally intended request.\");","    return;","}",""]}}],"collection":"6f8223d4-497c-4d0f-8df4-b7a92ac208b5","folder":null,"order":["d24d2650-e5ad-430d-afcc-bc98216525e8","bf62e806-9c9c-499e-b0d3-3bde9b759e64","35d67d50-5649-4ba0-8a9c-68e896bbcaea","f55d2885-2f0f-42ad-8101-7b12833a0215","8c37d7b2-7ce4-431d-a799-98bd9c2befa5","579a8c28-9ed4-4a03-8266-b06a6b9b17a4","8d9cd421-1d30-465b-94f8-3daa1731f5cd"],"folders_order":[],"collectionId":"6f8223d4-497c-4d0f-8df4-b7a92ac208b5","folderId":"3d1eadea-4a32-47ee-b8d9-24545112f994"}],"requests":[{"id":"13a2482e-1d01-4b04-8c48-ac4b1dbe68c0","name":"000 Environment Initialization","url":"https:\/\/raw.githubusercontent.com\/kjur\/jsrsasign\/master\/jsrsasign-all-min.js","description":"Run utility scripts and store it in global variable for supplemental use.","data":[],"dataMode":"params","headerData":[],"method":"GET","pathVariableData":[],"queryParams":[],"auth":null,"events":[{"listen":"prerequest","script":{"id":"06c0466b-b201-4264-be3b-b8fefbc7aa53","type":"text\/javascript","exec":["\/***** README *****\/","\/*"," * - WARNING: THIS SCRIPT WILL ERASE ALL GLOBAL AND ENVIRONMENT VARIABLES."," * - The scripts in Pre-request Script and Tests tabs populate all necessary global and environmental variables assuming the user just installed Postman application and start out fresh. After running this script, the user shall be equipped to run any other individual Scenario or entire Demo folder via Runner."," * - Expiration of Bearer Token is fixed at one hour, while that of JWT is configurable, but defaulted at ten minutes for security consideration."," * - Implementation High Levels"," *   a. Assign essential variables (including reusable functions to validate token and handle failed requests)"," *   b. Get and compile JsRsaSign scripts"," *   c. Synthesize JWT offline"," *   d. Request Bearer Token"," *   e. Create a new case"," *   f. Get the newly created case","*\/ ","","","\/***** Globals & Environment Variables Cleansing *****\/","pm.globals.clear(); \/\/ Wipe out global variables","pm.environment.clear(); \/\/ Wipe out environment variables","","","\/***** USER CREDENTIALS *****\/","\/\/ Partner Cert Thumbprint. See https:\/\/docs.microsoft.com\/en-us\/dotnet\/framework\/wcf\/feature-details\/how-to-retrieve-the-thumbprint-of-a-certificate","pm.environment.set(\"020_ThumbPrint\", \"\");","\/\/ Partner Client\/App ID","pm.environment.set(\"020_ClientId\", \"\");","\/\/ Partner Tenant ID","pm.environment.set(\"020_TenantId\", \"\");","\/\/ Partner PEM private key string","pm.environment.set(\"020_PrivateKey\", \"\");","\/\/ Support Area Path (SAP) to route cases to Azure Stack team","pm.environment.set(\"100_SupportAreaPath\", \"\");","","let redFlag = false;","","function validateCredential(variableName){","    if(!(pm.environment.get(variableName).replace(\/^\\s+\/, '').replace(\/\\s+$\/, ''))){","        console.log(variableName + \" has no value. Please provide it.\");","        redFlag = true;","    }","}","","validateCredential(\"020_ThumbPrint\");","validateCredential(\"020_ClientId\");","validateCredential(\"020_TenantId\");","validateCredential(\"020_PrivateKey\");","validateCredential(\"100_SupportAreaPath\");","","if(redFlag)","    return;","    ","","\/***** OTHER SYSTEM PARAMETERS *****\/","pm.environment.set(\"020_GrantType\", \"client_credentials\");","pm.environment.set(\"020_Resource\", \"https:\/\/api-ppe.support.microsoft.com\");","pm.environment.set(\"020_ClientAssertionType\", \"urn:ietf:params:oauth:client-assertion-type:jwt-bearer\");","pm.environment.set(\"100s_200s_BaseUrl\", \"https:\/\/api-ppe.support.microsoft.com\/v1\/cases\");","","","\/***** VALIDATE ACCESS TOKEN AND UPDATE IF NEEDED *****\/","postman.setGlobalVariable(\"validateAndUpdateToken\", (forceUpdate) => {","    let bearerToken = pm.environment.get(\"100s_200s_BearerToken\");","    let now = new Date().getTime() \/ 1000 | 0;","","    if(!forceUpdate){ \/\/ not forcing token update","        if(bearerToken){ \/\/ Bearer Token is present","            let jwtClaims = new Buffer(bearerToken.split(\".\")[1], \"base64\").toString('ascii'); \/\/ cell 0 contains header, cell 1 contains claims, and cell 2 contains signature ","            let jwtExpTimestamp = JSON.parse(jwtClaims).exp;","            if(jwtExpTimestamp - now > 10) \/\/ token expiration is more than 10 secs out from now","                return; \/\/ Skip token-update script below if not forcing token update, token is present, and not expired","        }","    }","    ","    \/\/ Compile JsRsaSign script just retrieved from Github","    let navigator = {}; \/\/fake a navigator object for the lib","    let window = {}; \/\/fake a window object for the lib","    eval(pm.globals.get(\"020_JsRsaSign\"));","    ","    \/\/ Prepare JWT elements offline","    let privateKey = pm.environment.get(\"020_PrivateKey\"); \/\/ Private Key from pem file","    let tenantId = pm.environment.get(\"020_TenantId\");","    let clientId = pm.environment.get(\"020_ClientId\");","    let authorizationUrl = \"https:\/\/login.microsoftonline.com\/\" + tenantId + \"\/oauth2\/token\";","    let baseUrl = pm.environment.get(\"100s_200s_BaseUrl\");","    let x5t = Buffer(pm.environment.get(\"020_ThumbPrint\"), \"hex\").toString(\"base64\").replace(\/=\/g, '').replace(\/\\+\/g, '-').replace(\/\\\/\/g, '_'); \/\/ Thumbprint in Base64URL format","    ","    \/\/ Synthesize JWT offline","    let header = { ","        alg: \"RS256\", ","        typ: \"JWT\", ","        x5t: x5t","        };","    let payload = { ","        aud: authorizationUrl, \/\/ Authorization Server end point","        nbf: now, \/\/ Right now","        exp: now + 600, \/\/ 10 mins from now. Can be longer, but not advisible for security concern","        jti: require(\"uuid\").v4(), \/\/ Random GUID","        iss: clientId, \/\/ App ID","        sub: clientId \/\/ App ID","        };","    let jwt = KJUR.jws.JWS.sign(\"RS256\", header, payload, privateKey);","","    \/\/ Prepare specs for requesting Bearer Token","    const tokenRequestSpecs = {","      url: authorizationUrl,","      method: \"POST\",","        header: \"Content-Type:multipart\/form-data\",","        body: {","            mode: \"formdata\",","            formdata: [","                {key: \"grant_type\", value: pm.environment.get(\"020_GrantType\")},","                {key: \"resource\", value: pm.environment.get(\"020_Resource\")},","                {key: \"client_assertion_type\", value: pm.environment.get(\"020_ClientAssertionType\")},","                {key: \"client_assertion\", value: jwt}","            ]","        }","    };","    ","    \/\/ Makes POST: request Bearer Token","    pm.sendRequest(tokenRequestSpecs, function (err, res) {","        if(err){","            console.log(err);","        } else {","            \/\/ Store Bearer Token as global variable","            pm.environment.set(\"100s_200s_BearerToken\", res.json().access_token);","        }","    });","});",""]}},{"listen":"test","script":{"id":"c3f6a13d-b8fc-4027-b62b-593a679a1d90","type":"text\/javascript","exec":["\/***** SYNTHESIZE JWT AND REQUEST ACCESS TOKEN *****\/","pm.globals.set(\"020_JsRsaSign\", pm.response.text()); \/\/ Store JsRsaSign script as Global variable","eval(pm.globals.get(\"validateAndUpdateToken\"))(true); \/\/ compile and execute validateAndUpdateToken() to forcefully getting new token regardless what token is at hand","","","\/***** CREATE AND GET NEW CASE *****\/","\/\/ Draft \"POST Case\" payload","let now = new Date().getTime() \/ 1000 | 0;","let sap = pm.environment.get(\"100_SupportAreaPath\");","let delay = 5000; \/\/ General time delay before making next request","let caseJson = {","  \"SupportAreaPath\": sap,","  \"Severity\": \"2\",","  \"CreationChannel\": \"Web\",","  \"Title\": \"Test \" + now,","  \"IssueDescription\": \"This is a description of the issue.\",","  \"SupportCountry\": \"US\",","  \"SupportLanguage\": \"en-US\",","  \"EntitlementInformation\": {","    \"EntitlementId\": \"U291cmNlOkZyZWUsRnJlZUlkOjAwMDAwMDAwLTAwMDAtMDAwMC0wMDAwLTAwMDAwMDAwMDAwMCxMb2NhbGU6ZW4tdXMs\"","  },","  \"Customers\": [","    {","      \"CustomerId\": \"Unknown\",","      \"CustomerIdSource\": \"Unknown\",","      \"Contacts\": [","        {","            \"FirstName\": \"John\",","            \"LastName\": \"Smith\",","            \"Email\": \"JohnSmith@invalidCustomerEmail.com\",","            \"Phone\": \"+123-456-7890\",","            \"PreferredContactChannel\": \"Phone\",","            \"IsPrimaryContact\": true","        }","      ]","    }","  ],","  \"PartnerCaseReferences\": [","    {","        \"PartnerCaseId\": \"Test \" + now,","        \"PartnerCaseState\": \"Open\",","        \"PartnerAgentInformation\": {","            \"FirstName\": \"Jane\",","            \"LastName\": \"Doe\",","            \"Email\": \"JaneDoe@invalidPartnerEmail.com\",","            \"Phone\": \"+888-999-0000\"","        }","    }","  ]","};","","setTimeout(function(){","    let baseUrl = pm.environment.get(\"100s_200s_BaseUrl\");","    let bearerToken = pm.environment.get(\"100s_200s_BearerToken\");","    ","    \/\/ Prepare specs for creating a new case","    const postRequestSpecs = {","          url: baseUrl,","          method: \"POST\",","          header: {","              \"Content-Type\": \"application\/json\", ","              \"Authorization\": \"Bearer \" + bearerToken","          },","          body: {","            mode: \"raw\",","            raw: JSON.stringify(caseJson)","          }","        };","    ","    \/\/ Makes POST: creates new case","    pm.sendRequest(postRequestSpecs, function (err, res) {","            if(err){","                console.log(err);","            } else if (res.code != 201) { \/\/ No error, but request not successful","                console.log(res);","            } else { \/\/ Request Success","                let caseNumber = res.json().CaseNumber;","                pm.environment.set(\"100s_200s_CaseNumber\", caseNumber);","                setTimeout(function(){","                    \/\/ Makes GET: acquires casejson of the newly created case","                    pm.sendRequest({","                        url: baseUrl + \"\/\" + caseNumber,","                        method: \"GET\",","                        header: \"Authorization:Bearer \" + bearerToken","                    });","                }, delay); \/\/ Allocate time buffer to allow remote server to complete new case creation before our GET request","            }","        });","}, delay); \/\/ Allocate time buffer to allow Postman to obtain access token before our next POST request (create case)","",""]}}],"folder":null,"preRequestScript":"\/***** README *****\/\n\/*\n * - WARNING: THIS SCRIPT WILL ERASE ALL GLOBAL AND ENVIRONMENT VARIABLES.\n * - The scripts in Pre-request Script and Tests tabs populate all necessary global and environmental variables assuming the user just installed Postman application and start out fresh. After running this script, the user shall be equipped to run any other individual Scenario or entire Demo folder via Runner.\n * - Expiration of Bearer Token is fixed at one hour, while that of JWT is configurable, but defaulted at ten minutes for security consideration.\n * - Implementation High Levels\n *   a. Assign essential variables (including reusable functions to validate token and handle failed requests)\n *   b. Get and compile JsRsaSign scripts\n *   c. Synthesize JWT offline\n *   d. Request Bearer Token\n *   e. Create a new case\n *   f. Get the newly created case\n*\/ \n\n\n\/***** Globals & Environment Variables Cleansing *****\/\npm.globals.clear(); \/\/ Wipe out global variables\npm.environment.clear(); \/\/ Wipe out environment variables\n\n\n\/***** USER CREDENTIALS *****\/\n\/\/ Partner Cert Thumbprint. See https:\/\/docs.microsoft.com\/en-us\/dotnet\/framework\/wcf\/feature-details\/how-to-retrieve-the-thumbprint-of-a-certificate\npm.environment.set(\"020_ThumbPrint\", \"\");\n\/\/ Partner Client\/App ID\npm.environment.set(\"020_ClientId\", \"\");\n\/\/ Partner Tenant ID\npm.environment.set(\"020_TenantId\", \"\");\n\/\/ Partner PEM private key string\npm.environment.set(\"020_PrivateKey\", \"\");\n\/\/ Support Area Path (SAP) to route cases to Azure Stack team\npm.environment.set(\"100_SupportAreaPath\", \"\");\n\nlet redFlag = false;\n\nfunction validateCredential(variableName){\n    if(!(pm.environment.get(variableName).replace(\/^\\s+\/, '').replace(\/\\s+$\/, ''))){\n        console.log(variableName + \" has no value. Please provide it.\");\n        redFlag = true;\n    }\n}\n\nvalidateCredential(\"020_ThumbPrint\");\nvalidateCredential(\"020_ClientId\");\nvalidateCredential(\"020_TenantId\");\nvalidateCredential(\"020_PrivateKey\");\nvalidateCredential(\"100_SupportAreaPath\");\n\nif(redFlag)\n    return;\n    \n\n\/***** OTHER SYSTEM PARAMETERS *****\/\npm.environment.set(\"020_GrantType\", \"client_credentials\");\npm.environment.set(\"020_Resource\", \"https:\/\/api-ppe.support.microsoft.com\");\npm.environment.set(\"020_ClientAssertionType\", \"urn:ietf:params:oauth:client-assertion-type:jwt-bearer\");\npm.environment.set(\"100s_200s_BaseUrl\", \"https:\/\/api-ppe.support.microsoft.com\/v1\/cases\");\n\n\n\/***** VALIDATE ACCESS TOKEN AND UPDATE IF NEEDED *****\/\npostman.setGlobalVariable(\"validateAndUpdateToken\", (forceUpdate) => {\n    let bearerToken = pm.environment.get(\"100s_200s_BearerToken\");\n    let now = new Date().getTime() \/ 1000 | 0;\n\n    if(!forceUpdate){ \/\/ not forcing token update\n        if(bearerToken){ \/\/ Bearer Token is present\n            let jwtClaims = new Buffer(bearerToken.split(\".\")[1], \"base64\").toString('ascii'); \/\/ cell 0 contains header, cell 1 contains claims, and cell 2 contains signature \n            let jwtExpTimestamp = JSON.parse(jwtClaims).exp;\n            if(jwtExpTimestamp - now > 10) \/\/ token expiration is more than 10 secs out from now\n                return; \/\/ Skip token-update script below if not forcing token update, token is present, and not expired\n        }\n    }\n    \n    \/\/ Compile JsRsaSign script just retrieved from Github\n    let navigator = {}; \/\/fake a navigator object for the lib\n    let window = {}; \/\/fake a window object for the lib\n    eval(pm.globals.get(\"020_JsRsaSign\"));\n    \n    \/\/ Prepare JWT elements offline\n    let privateKey = pm.environment.get(\"020_PrivateKey\"); \/\/ Private Key from pem file\n    let tenantId = pm.environment.get(\"020_TenantId\");\n    let clientId = pm.environment.get(\"020_ClientId\");\n    let authorizationUrl = \"https:\/\/login.microsoftonline.com\/\" + tenantId + \"\/oauth2\/token\";\n    let baseUrl = pm.environment.get(\"100s_200s_BaseUrl\");\n    let x5t = Buffer(pm.environment.get(\"020_ThumbPrint\"), \"hex\").toString(\"base64\").replace(\/=\/g, '').replace(\/\\+\/g, '-').replace(\/\\\/\/g, '_'); \/\/ Thumbprint in Base64URL format\n    \n    \/\/ Synthesize JWT offline\n    let header = { \n        alg: \"RS256\", \n        typ: \"JWT\", \n        x5t: x5t\n        };\n    let payload = { \n        aud: authorizationUrl, \/\/ Authorization Server end point\n        nbf: now, \/\/ Right now\n        exp: now + 600, \/\/ 10 mins from now. Can be longer, but not advisible for security concern\n        jti: require(\"uuid\").v4(), \/\/ Random GUID\n        iss: clientId, \/\/ App ID\n        sub: clientId \/\/ App ID\n        };\n    let jwt = KJUR.jws.JWS.sign(\"RS256\", header, payload, privateKey);\n\n    \/\/ Prepare specs for requesting Bearer Token\n    const tokenRequestSpecs = {\n      url: authorizationUrl,\n      method: \"POST\",\n        header: \"Content-Type:multipart\/form-data\",\n        body: {\n            mode: \"formdata\",\n            formdata: [\n                {key: \"grant_type\", value: pm.environment.get(\"020_GrantType\")},\n                {key: \"resource\", value: pm.environment.get(\"020_Resource\")},\n                {key: \"client_assertion_type\", value: pm.environment.get(\"020_ClientAssertionType\")},\n                {key: \"client_assertion\", value: jwt}\n            ]\n        }\n    };\n    \n    \/\/ Makes POST: request Bearer Token\n    pm.sendRequest(tokenRequestSpecs, function (err, res) {\n        if(err){\n            console.log(err);\n        } else {\n            \/\/ Store Bearer Token as global variable\n            pm.environment.set(\"100s_200s_BearerToken\", res.json().access_token);\n        }\n    });\n});\n","tests":"\/***** SYNTHESIZE JWT AND REQUEST ACCESS TOKEN *****\/\npm.globals.set(\"020_JsRsaSign\", pm.response.text()); \/\/ Store JsRsaSign script as Global variable\neval(pm.globals.get(\"validateAndUpdateToken\"))(true); \/\/ compile and execute validateAndUpdateToken() to forcefully getting new token regardless what token is at hand\n\n\n\/***** CREATE AND GET NEW CASE *****\/\n\/\/ Draft \"POST Case\" payload\nlet now = new Date().getTime() \/ 1000 | 0;\nlet sap = pm.environment.get(\"100_SupportAreaPath\");\nlet delay = 5000; \/\/ General time delay before making next request\nlet caseJson = {\n  \"SupportAreaPath\": sap,\n  \"Severity\": \"2\",\n  \"CreationChannel\": \"Web\",\n  \"Title\": \"Test \" + now,\n  \"IssueDescription\": \"This is a description of the issue.\",\n  \"SupportCountry\": \"US\",\n  \"SupportLanguage\": \"en-US\",\n  \"EntitlementInformation\": {\n    \"EntitlementId\": \"U291cmNlOkZyZWUsRnJlZUlkOjAwMDAwMDAwLTAwMDAtMDAwMC0wMDAwLTAwMDAwMDAwMDAwMCxMb2NhbGU6ZW4tdXMs\"\n  },\n  \"Customers\": [\n    {\n      \"CustomerId\": \"Unknown\",\n      \"CustomerIdSource\": \"Unknown\",\n      \"Contacts\": [\n        {\n            \"FirstName\": \"John\",\n            \"LastName\": \"Smith\",\n            \"Email\": \"JohnSmith@invalidCustomerEmail.com\",\n            \"Phone\": \"+123-456-7890\",\n            \"PreferredContactChannel\": \"Phone\",\n            \"IsPrimaryContact\": true\n        }\n      ]\n    }\n  ],\n  \"PartnerCaseReferences\": [\n    {\n        \"PartnerCaseId\": \"Test \" + now,\n        \"PartnerCaseState\": \"Open\",\n        \"PartnerAgentInformation\": {\n            \"FirstName\": \"Jane\",\n            \"LastName\": \"Doe\",\n            \"Email\": \"JaneDoe@invalidPartnerEmail.com\",\n            \"Phone\": \"+888-999-0000\"\n        }\n    }\n  ]\n};\n\nsetTimeout(function(){\n    let baseUrl = pm.environment.get(\"100s_200s_BaseUrl\");\n    let bearerToken = pm.environment.get(\"100s_200s_BearerToken\");\n    \n    \/\/ Prepare specs for creating a new case\n    const postRequestSpecs = {\n          url: baseUrl,\n          method: \"POST\",\n          header: {\n              \"Content-Type\": \"application\/json\", \n              \"Authorization\": \"Bearer \" + bearerToken\n          },\n          body: {\n            mode: \"raw\",\n            raw: JSON.stringify(caseJson)\n          }\n        };\n    \n    \/\/ Makes POST: creates new case\n    pm.sendRequest(postRequestSpecs, function (err, res) {\n            if(err){\n                console.log(err);\n            } else if (res.code != 201) { \/\/ No error, but request not successful\n                console.log(res);\n            } else { \/\/ Request Success\n                let caseNumber = res.json().CaseNumber;\n                pm.environment.set(\"100s_200s_CaseNumber\", caseNumber);\n                setTimeout(function(){\n                    \/\/ Makes GET: acquires casejson of the newly created case\n                    pm.sendRequest({\n                        url: baseUrl + \"\/\" + caseNumber,\n                        method: \"GET\",\n                        header: \"Authorization:Bearer \" + bearerToken\n                    });\n                }, delay); \/\/ Allocate time buffer to allow remote server to complete new case creation before our GET request\n            }\n        });\n}, delay); \/\/ Allocate time buffer to allow Postman to obtain access token before our next POST request (create case)\n\n","currentHelper":null,"helperAttributes":null,"collectionId":"6f8223d4-497c-4d0f-8df4-b7a92ac208b5","headers":"","pathVariables":[]},{"id":"35d67d50-5649-4ba0-8a9c-68e896bbcaea","name":"120 Note Create","url":"{{100s_200s_BaseUrl}}\/{{100s_200s_CaseNumber}}\/notes","description":"URL: Use the case SR number and the ID.  --  v1\/cases\/{SR}\/notes","data":[],"dataMode":"raw","headerData":[{"key":"Authorization","value":"Bearer {{100s_200s_BearerToken}}"},{"key":"Content-Type","value":"application\/json"}],"method":"POST","pathVariableData":[],"queryParams":[],"auth":null,"events":[{"listen":"prerequest","script":{"id":"1f46b156-d13a-4fc2-a69a-ae90deab0e3a","type":"text\/javascript","exec":["\/***** PARSE CurrentDateTime *****\/","var date = new Date();","","var hour = date.getHours();","hour = (hour < 10 ? \"0\" : \"\") + hour;","","var min = date.getMinutes();","min = (min < 10 ? \"0\" : \"\") + min;","","var sec = date.getSeconds();","sec = (sec < 10 ? \"0\" : \"\") + sec;","","var year = date.getFullYear();","","var month = date.getMonth() + 1;","month = (month < 10 ? \"0\" : \"\") + month;","","var day = date.getDate();","day = (day < 10 ? \"0\" : \"\") + day;","","pm.environment.set(\"100s_200s_CurrentDateTime\", year + \"\/\" + month + \"\/\" + day + \", \" + hour + \":\" + min + \":\" + sec);"]}},{"listen":"test","script":{"id":"4e091ea7-de3f-42c5-8b7b-b501fa67b5d3","type":"text\/javascript","exec":[""]}}],"folder":"3d1eadea-4a32-47ee-b8d9-24545112f994","preRequestScript":"\/***** PARSE CurrentDateTime *****\/\nvar date = new Date();\n\nvar hour = date.getHours();\nhour = (hour < 10 ? \"0\" : \"\") + hour;\n\nvar min = date.getMinutes();\nmin = (min < 10 ? \"0\" : \"\") + min;\n\nvar sec = date.getSeconds();\nsec = (sec < 10 ? \"0\" : \"\") + sec;\n\nvar year = date.getFullYear();\n\nvar month = date.getMonth() + 1;\nmonth = (month < 10 ? \"0\" : \"\") + month;\n\nvar day = date.getDate();\nday = (day < 10 ? \"0\" : \"\") + day;\n\npm.environment.set(\"100s_200s_CurrentDateTime\", year + \"\/\" + month + \"\/\" + day + \", \" + hour + \":\" + min + \":\" + sec);","tests":null,"currentHelper":null,"helperAttributes":null,"collectionId":"6f8223d4-497c-4d0f-8df4-b7a92ac208b5","rawModeData":"{\r\n  \"Content\": \"<div style='color: rgb(0, 0, 0); font-family: Calibri,Arial,Helvetica,sans-serif; font-size: 11pt;'>Test Note {{100s_200s_CurrentDateTime}}<br><\/div>\"\r\n}\r\n","headers":"Authorization: Bearer {{100s_200s_BearerToken}}\nContent-Type: application\/json\n","pathVariables":[]},{"id":"579a8c28-9ed4-4a03-8266-b06a6b9b17a4","name":"200 v1 Get Case","url":"{{100s_200s_BaseUrl}}\/{{100s_200s_CaseNumber}}","description":null,"data":[],"dataMode":"raw","headerData":[{"key":"Authorization","value":"Bearer {{100s_200s_BearerToken}}"}],"method":"GET","pathVariableData":[],"queryParams":[],"auth":null,"events":[{"listen":"prerequest","script":{"id":"ac052e12-f54e-4cb9-9606-d0ede86a9a09","type":"text\/javascript","exec":[""]}},{"listen":"test","script":{"id":"5a72188d-1e85-4498-abbb-2e0280763e1e","type":"text\/javascript","exec":["\/***** GET PARTNER CASE REFERENCE ID GUID *****\/","let caseJson = pm.response.json();","","if(!caseJson || !caseJson.CaseNumber){","    console.log(\"Case JSON is absent.\");","    return;","}","","let pcrs = caseJson.PartnerCaseReferences;","","if(!pcrs){","    console.log(\"Partner Case References array is absent.\");","    return;","} else {","    let partnerId = pm.environment.get(\"020_ClientId\");","    ","    for (i = 0; i < pcrs.length; i++) { ","        if(pcrs[i].PartnerId == partnerId)","            pm.environment.set(\"110_PartnerCaseReferenceIdGuid\", pcrs[i].id);","    }","}","","","\/***** GET DEFAULT CUSTOMER ID GUID *****\/","let defaultCustomer = caseJson.Customers[0];","","if(!defaultCustomer){","    console.log(\"Default Customer is absent.\");","    return;","} else {","    pm.environment.set(\"140_DefaultCustomerIdGuid\", defaultCustomer.id);","}","","","\/***** GET NEWEST CONTACT ID GUID *****\/","let contacts = caseJson.Customers[0].Contacts;","","if(!contacts){","    console.log(\"Contacts array is absent.\");","    return;","} else {","    let newestDate = 0;","    let thisDate = 0;","    let indexOfNewestDate = 0;","    ","    for (j = 0; j < contacts.length; j++) {","        thisDate = Date.parse(contacts[j].CreatedOn);","        ","        if(thisDate > newestDate){","            indexOfNewestDate = j;","            newestDate = thisDate;","        }","    }","    ","    pm.environment.set(\"145_NewestContactIdGuid\", contacts[indexOfNewestDate].id);","}","","","\/***** PRINT NEWEST & SANITIZED NOTES *****\/","let notes = caseJson.Notes;","","if(!notes){","    console.log(\"Notes array is absent.\");","    return;","} else {","    newestDate = 0;","    thisDate = 0;","    indexOfNewestDate = 0;","    ","    for (k = 0; k < notes.length; k++) {","        console.log(notes[k].Content);","        thisDate = Date.parse(notes[k].CreatedOn);","        ","        if(thisDate > newestDate){","            indexOfNewestDate = k;","            newestDate = thisDate;","        }","    }","    ","    \/\/ WARNING: Using REGEX to sanitize HTML can incur serious security risk. APPLY REGEX AS LAST RESORT AND ONLY ON TRUSTED TEXT.","    console.log(\"Newest & Sanitized Note: \" + notes[indexOfNewestDate].Content.replace(\/<[^>]+>\/g, '')); \/\/ Apply Regex to sanitize HTML tags","}"]}}],"folder":"3d1eadea-4a32-47ee-b8d9-24545112f994","preRequestScript":null,"tests":"\/***** GET PARTNER CASE REFERENCE ID GUID *****\/\nlet caseJson = pm.response.json();\n\nif(!caseJson || !caseJson.CaseNumber){\n    console.log(\"Case JSON is absent.\");\n    return;\n}\n\nlet pcrs = caseJson.PartnerCaseReferences;\n\nif(!pcrs){\n    console.log(\"Partner Case References array is absent.\");\n    return;\n} else {\n    let partnerId = pm.environment.get(\"020_ClientId\");\n    \n    for (i = 0; i < pcrs.length; i++) { \n        if(pcrs[i].PartnerId == partnerId)\n            pm.environment.set(\"110_PartnerCaseReferenceIdGuid\", pcrs[i].id);\n    }\n}\n\n\n\/***** GET DEFAULT CUSTOMER ID GUID *****\/\nlet defaultCustomer = caseJson.Customers[0];\n\nif(!defaultCustomer){\n    console.log(\"Default Customer is absent.\");\n    return;\n} else {\n    pm.environment.set(\"140_DefaultCustomerIdGuid\", defaultCustomer.id);\n}\n\n\n\/***** GET NEWEST CONTACT ID GUID *****\/\nlet contacts = caseJson.Customers[0].Contacts;\n\nif(!contacts){\n    console.log(\"Contacts array is absent.\");\n    return;\n} else {\n    let newestDate = 0;\n    let thisDate = 0;\n    let indexOfNewestDate = 0;\n    \n    for (j = 0; j < contacts.length; j++) {\n        thisDate = Date.parse(contacts[j].CreatedOn);\n        \n        if(thisDate > newestDate){\n            indexOfNewestDate = j;\n            newestDate = thisDate;\n        }\n    }\n    \n    pm.environment.set(\"145_NewestContactIdGuid\", contacts[indexOfNewestDate].id);\n}\n\n\n\/***** PRINT NEWEST & SANITIZED NOTES *****\/\nlet notes = caseJson.Notes;\n\nif(!notes){\n    console.log(\"Notes array is absent.\");\n    return;\n} else {\n    newestDate = 0;\n    thisDate = 0;\n    indexOfNewestDate = 0;\n    \n    for (k = 0; k < notes.length; k++) {\n        console.log(notes[k].Content);\n        thisDate = Date.parse(notes[k].CreatedOn);\n        \n        if(thisDate > newestDate){\n            indexOfNewestDate = k;\n            newestDate = thisDate;\n        }\n    }\n    \n    \/\/ WARNING: Using REGEX to sanitize HTML can incur serious security risk. APPLY REGEX AS LAST RESORT AND ONLY ON TRUSTED TEXT.\n    console.log(\"Newest & Sanitized Note: \" + notes[indexOfNewestDate].Content.replace(\/<[^>]+>\/g, '')); \/\/ Apply Regex to sanitize HTML tags\n}","currentHelper":null,"helperAttributes":null,"collectionId":"6f8223d4-497c-4d0f-8df4-b7a92ac208b5","rawModeData":"{\r\n  \"Email\": \"test@gmail.com\",\r\n  \"FirstName\": \"Aaron\",\r\n  \"IsPrimaryContact\": true,\r\n  \"LastName\": \"Koller\",\r\n  \"Phone\": \"123-123-1234\",\r\n}","headers":"Authorization: Bearer {{100s_200s_BearerToken}}\n","pathVariables":[]},{"id":"8c37d7b2-7ce4-431d-a799-98bd9c2befa5","name":"145 Contact Update","url":"{{100s_200s_BaseUrl}}\/{{100s_200s_CaseNumber}}\/customers\/{{140_DefaultCustomerIdGuid}}\/contacts\/{{145_NewestContactIdGuid}}","description":null,"data":[],"dataMode":"raw","headerData":[{"key":"Authorization","value":"Bearer {{100s_200s_BearerToken}}"},{"key":"Content-Type","value":"application\/json"}],"method":"PATCH","pathVariableData":[],"queryParams":[],"auth":null,"events":[{"listen":"prerequest","script":{"id":"bea50627-f015-4704-a7b0-a316338197eb","type":"text\/javascript","exec":[""]}},{"listen":"test","script":{"id":"a96b4bd3-6927-441d-bb02-7505fb61f7c8","type":"text\/javascript","exec":[""]}}],"folder":"3d1eadea-4a32-47ee-b8d9-24545112f994","preRequestScript":null,"tests":null,"currentHelper":null,"helperAttributes":null,"collectionId":"6f8223d4-497c-4d0f-8df4-b7a92ac208b5","rawModeData":"{\r\n  \"Email\": \"B.Foo@invalidCustomerEmail.com\",\r\n  \"FirstName\": \"Bar\",\r\n  \"IsPrimaryContact\": true,\r\n  \"LastName\": \"Foo\",\r\n  \"Phone\": \"+{{$randomInt}} {{$randomInt}}-{{$randomInt}}-9{{$randomInt}}\",\r\n  \"PreferredContactChannel\": \"Email\"\r\n}","headers":"Authorization: Bearer {{100s_200s_BearerToken}}\nContent-Type: application\/json\n","pathVariables":[]},{"id":"8d9cd421-1d30-465b-94f8-3daa1731f5cd","name":"xxx clase closed","url":"{{100s_200s_BaseUrl}}\/{{100s_200s_CaseNumber}}\/partnerCaseReferences\/{{110_PartnerCaseReferenceIdGuid}}","description":"URL: Use the case SR number and the PartnerCaseReference Guid Id.  --  v1\/cases\/{SR}\/partnerCaseReferences\/{id}","data":[],"dataMode":"raw","headerData":[{"key":"Authorization","value":"Bearer {{100s_200s_BearerToken}}"},{"key":"Content-Type","value":"application\/json"}],"method":"PATCH","pathVariableData":[],"queryParams":[],"auth":{"type":"noauth"},"events":[{"listen":"prerequest","script":{"id":"cc7b453c-2772-41e9-a302-b3ea4ca7b80f","type":"text\/javascript","exec":[""]}},{"listen":"test","script":{"id":"99c9fe82-6dca-4ffc-8ccb-4d51099d026b","type":"text\/javascript","exec":[""]}}],"folder":"3d1eadea-4a32-47ee-b8d9-24545112f994","preRequestScript":null,"tests":null,"currentHelper":null,"helperAttributes":null,"collectionId":"6f8223d4-497c-4d0f-8df4-b7a92ac208b5","rawModeData":"{\r\n  \"PartnerCaseState\": \"Closed\"\r\n}","headers":"Authorization: Bearer {{100s_200s_BearerToken}}\nContent-Type: application\/json\n","pathVariables":[]},{"id":"be3937b5-7640-4e0c-a5a6-aeafe65d7f71","name":"120 Note Update","url":"{{100s_200s_BaseUrl}}\/{{100s_200s_CaseNumber}}\/notes\/01b7f884-fc88-46e2-ac03-80745d52380c","description":"URL: Use the case SR number and the ID.  --  v1\/cases\/{SR}\/notes","data":[],"dataMode":"raw","headerData":[{"key":"Authorization","value":"Bearer {{100s_200s_BearerToken}}"},{"key":"Content-Type","value":"application\/json"}],"method":"PATCH","pathVariableData":[],"queryParams":[],"auth":null,"events":[{"listen":"prerequest","script":{"id":"831bc472-a6d8-4574-b00e-fb419ac17947","type":"text\/javascript","exec":["var date = new Date();","","var hour = date.getHours();","hour = (hour < 10 ? \"0\" : \"\") + hour;","","var min = date.getMinutes();","min = (min < 10 ? \"0\" : \"\") + min;","","var sec = date.getSeconds();","sec = (sec < 10 ? \"0\" : \"\") + sec;","","var year = date.getFullYear();","","var month = date.getMonth() + 1;","month = (month < 10 ? \"0\" : \"\") + month;","","var day = date.getDate();","day = (day < 10 ? \"0\" : \"\") + day;","","pm.environment.set(\"100s_200s_CurrentDateTime\", year + \"\/\" + month + \"\/\" + day + \", \" + hour + \":\" + min + \":\" + sec);"]}}],"folder":"db2fe451-be2a-4a07-ba09-f24803f35e4e","preRequestScript":"var date = new Date();\n\nvar hour = date.getHours();\nhour = (hour < 10 ? \"0\" : \"\") + hour;\n\nvar min = date.getMinutes();\nmin = (min < 10 ? \"0\" : \"\") + min;\n\nvar sec = date.getSeconds();\nsec = (sec < 10 ? \"0\" : \"\") + sec;\n\nvar year = date.getFullYear();\n\nvar month = date.getMonth() + 1;\nmonth = (month < 10 ? \"0\" : \"\") + month;\n\nvar day = date.getDate();\nday = (day < 10 ? \"0\" : \"\") + day;\n\npm.environment.set(\"100s_200s_CurrentDateTime\", year + \"\/\" + month + \"\/\" + day + \", \" + hour + \":\" + min + \":\" + sec);","tests":null,"currentHelper":null,"helperAttributes":null,"collectionId":"6f8223d4-497c-4d0f-8df4-b7a92ac208b5","rawModeData":"{\r\n  \"Content\": \"<div style='color: rgb(0, 0, 0); font-family: Calibri,Arial,Helvetica,sans-serif; font-size: 11pt;'>Updated Test Note {{100s_200s_CurrentDateTime}}<br><\/div>\"\r\n}\r\n\r\n","headers":"Authorization: Bearer {{100s_200s_BearerToken}}\nContent-Type: application\/json\n","pathVariables":[]},{"id":"bf62e806-9c9c-499e-b0d3-3bde9b759e64","name":"110 P. Agent Assigned","url":"{{100s_200s_BaseUrl}}\/{{100s_200s_CaseNumber}}\/partnerCaseReferences\/{{110_PartnerCaseReferenceIdGuid}}","description":"URL: Use the case SR number and the PartnerCaseReference Guid Id.  --  v1\/cases\/{SR}\/partnerCaseReferences\/{id}","data":[],"dataMode":"raw","headerData":[{"key":"Authorization","value":"Bearer {{100s_200s_BearerToken}}"},{"key":"Content-Type","value":"application\/json","description":""}],"method":"PATCH","pathVariableData":[],"queryParams":[],"auth":null,"events":[{"listen":"prerequest","script":{"id":"5683e5c6-a163-4251-8914-9742ed658d5a","type":"text\/javascript","exec":[""]}},{"listen":"test","script":{"id":"04e50ab1-0362-4125-8d75-1105afeff85b","type":"text\/javascript","exec":[""]}}],"folder":"3d1eadea-4a32-47ee-b8d9-24545112f994","preRequestScript":null,"tests":null,"currentHelper":null,"helperAttributes":null,"collectionId":"6f8223d4-497c-4d0f-8df4-b7a92ac208b5","rawModeData":"{\r\n  \"PartnerCaseId\": \"TestID_{{$randomInt}}\",\r\n  \"PartnerAgentInformation\": {\r\n    \"Email\": \"Jed.I.Knighit@invalidPartnerEmail.com\",\r\n    \"Phone\": \"+{{$randomInt}} {{$randomInt}}-{{$randomInt}}-{{$randomInt}}\",\r\n    \"LastName\": \"Knighit\",\r\n    \"FirstName\": \"Jed I\"\r\n  }\r\n}","headers":"Authorization: Bearer {{100s_200s_BearerToken}}\nContent-Type: application\/json\n","pathVariables":[]},{"id":"d24d2650-e5ad-430d-afcc-bc98216525e8","name":"100 SandBox Create a Case","url":"{{100s_200s_BaseUrl}}","description":null,"data":[],"dataMode":"raw","headerData":[{"key":"Authorization","value":"Bearer {{100s_200s_BearerToken}}"},{"key":"Content-Type","value":"application\/json"}],"method":"POST","pathVariableData":[],"queryParams":[],"auth":null,"events":[{"listen":"test","script":{"id":"f1ae82b2-9dd6-495f-9e99-a4bd5e34221b","type":"text\/javascript","exec":["\/***** STORE CASE NUMBER *****\/","pm.environment.set(\"100s_200s_CaseNumber\", pm.response.json().CaseNumber);",""]}},{"listen":"prerequest","script":{"id":"7b4b4bde-085d-481c-a663-4f7abfb1a4ff","type":"text\/javascript","exec":[""]}}],"folder":"3d1eadea-4a32-47ee-b8d9-24545112f994","preRequestScript":null,"tests":"\/***** STORE CASE NUMBER *****\/\npm.environment.set(\"100s_200s_CaseNumber\", pm.response.json().CaseNumber);\n","currentHelper":null,"helperAttributes":null,"collectionId":"6f8223d4-497c-4d0f-8df4-b7a92ac208b5","rawModeData":"{\r\n  \"SupportAreaPath\": \"{{100_SupportAreaPath}}\",\r\n  \"Severity\": \"2\",\r\n  \"CreationChannel\": \"Web\",\r\n  \"Title\": \"Test {{$timestamp}}\",\r\n  \"IssueDescription\": \"This is a random {{$randomInt}} description of the issue with timestamp: '{{$timestamp}}'\",\r\n  \"SupportCountry\": \"US\",\r\n  \"SupportLanguage\": \"en-US\",\r\n  \"EntitlementInformation\": {\r\n    \"EntitlementId\": \"U291cmNlOkZyZWUsRnJlZUlkOjAwMDAwMDAwLTAwMDAtMDAwMC0wMDAwLTAwMDAwMDAwMDAwMCxMb2NhbGU6ZW4tdXMs\"\r\n  },\r\n  \"Customers\": [\r\n    {\r\n      \"CustomerId\": \"Unknown\",\r\n      \"CustomerIdSource\": \"Unknown\",\r\n      \"Contacts\": [\r\n        {\r\n        \t\"FirstName\": \"Joe\",\r\n            \"LastName\": \"Smith\",\r\n            \"Email\": \"JoeSmith@invalidCustomerEmail.com\",\r\n            \"Phone\": \"+{{$randomInt}} {{$randomInt}}-{{$randomInt}}-{{$randomInt}}\",\r\n            \"PreferredContactChannel\": \"Email\",\r\n            \"IsPrimaryContact\": true\r\n        }\r\n      ]\r\n    }\r\n  ],\r\n  \"PartnerCaseReferences\": [\r\n    {\r\n    \t\"PartnerCaseId\": \"PCI {{$timestamp}}\",\r\n        \"PartnerCaseState\": \"Open\",\r\n        \"PartnerAgentInformation\": {\r\n            \"FirstName\": \"Maria\",\r\n            \"LastName\": \"Doe\",\r\n            \"Email\": \"Maria.Doe@invalidPartnerEmail.com\",\r\n            \"Phone\": \"+{{$randomInt}} {{$randomInt}}-{{$randomInt}}-{{$randomInt}}\"\r\n        }\r\n    }\r\n  ]\r\n}\r\n","headers":"Authorization: Bearer {{100s_200s_BearerToken}}\nContent-Type: application\/json\n","pathVariables":[]},{"id":"f55d2885-2f0f-42ad-8101-7b12833a0215","name":"140 Contact Create","url":"{{100s_200s_BaseUrl}}\/{{100s_200s_CaseNumber}}\/customers\/{{140_DefaultCustomerIdGuid}}\/contacts","description":"URL: Use the case SR number and the contacts Guid Id.  --  v1\/cases\/{SR}\/customers\/{id}\/contacts","data":[],"dataMode":"raw","headerData":[{"key":"Authorization","value":"Bearer {{100s_200s_BearerToken}}"},{"key":"Content-Type","value":"application\/json"}],"method":"POST","pathVariableData":[],"queryParams":[],"auth":null,"events":[{"listen":"prerequest","script":{"id":"69b37bdd-a0b9-4134-b6a6-02e9a306ed45","type":"text\/javascript","exec":[""]}},{"listen":"test","script":{"id":"b715361d-dc14-441d-9b2c-94db9156d89a","type":"text\/javascript","exec":[""]}}],"folder":"3d1eadea-4a32-47ee-b8d9-24545112f994","preRequestScript":null,"tests":null,"currentHelper":null,"helperAttributes":null,"collectionId":"6f8223d4-497c-4d0f-8df4-b7a92ac208b5","rawModeData":"{\r\n  \"Email\": \"Richard-Roe@invalidCustomerEmail.com\",\r\n  \"FirstName\": \"Richard\",\r\n  \"IsPrimaryContact\": true,\r\n  \"LastName\": \"Roe\",\r\n  \"Phone\": \"+{{$randomInt}} ({{$randomInt}}) {{$randomInt}}-0{{$randomInt}}\",\r\n  \"PreferredContactChannel\": \"Phone\"\r\n}","headers":"Authorization: Bearer {{100s_200s_BearerToken}}\nContent-Type: application\/json\n","pathVariables":[]}]}