Created
June 20, 2023 01:51
-
-
Save wheel5up/4af9a056b3e99b75af6ac6a8372d12b5 to your computer and use it in GitHub Desktop.
Postman user add collection Application API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"info": { | |
"_postman_id": "7daec753-37e3-41ce-aca5-c108d332c367", | |
"name": "Add sendgrid user records to confluence", | |
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", | |
"_exporter_id": "98609", | |
"_collection_link": "https://blue-shuttle-6120.postman.co/workspace/User-Adds~577d01e0-6cce-42c2-972a-6c7774fc2e78/collection/98609-7daec753-37e3-41ce-aca5-c108d332c367?action=share&creator=98609&source=collection_link" | |
}, | |
"item": [ | |
{ | |
"name": "Initialize template", | |
"event": [ | |
{ | |
"listen": "prerequest", | |
"script": { | |
"exec": [ | |
"console.log('iteration number'+pm.info.iteration)", | |
"if (pm.info.iteration != 0) {", | |
" postman.setNextRequest(\"search for confluence page\");", | |
"} else {", | |
" postman.setNextRequest(\"get template\");", | |
"} " | |
], | |
"type": "text/javascript" | |
} | |
}, | |
{ | |
"listen": "test", | |
"script": { | |
"exec": [ | |
"" | |
], | |
"type": "text/javascript" | |
} | |
} | |
], | |
"request": { | |
"auth": { | |
"type": "noauth" | |
}, | |
"method": "GET", | |
"header": [ | |
{ | |
"key": "Accept", | |
"type": "text", | |
"value": "application/json" | |
}, | |
{ | |
"key": "Content-Type", | |
"type": "text", | |
"value": "application/json" | |
} | |
], | |
"url": { | |
"raw": "https://postman-echo.com/status/200", | |
"protocol": "https", | |
"host": [ | |
"postman-echo", | |
"com" | |
], | |
"path": [ | |
"status", | |
"200" | |
] | |
} | |
}, | |
"response": [] | |
}, | |
{ | |
"name": "get template", | |
"event": [ | |
{ | |
"listen": "prerequest", | |
"script": { | |
"exec": [ | |
"console.log('iteration number'+pm.info.iteration)", | |
"if (pm.info.iteration != 0) {", | |
"// postman.setNextRequest(null);", | |
"//} else {", | |
" postman.setNextRequest(\"search for confluence page\");", | |
"} " | |
], | |
"type": "text/javascript" | |
} | |
}, | |
{ | |
"listen": "test", | |
"script": { | |
"exec": [ | |
" pm.test('Get template', function () {", | |
" var response = pm.response.json();", | |
" console.log(response.results[0].body.storage.value);", | |
" pm.variables.set(\"templatebody\",response.results[0].body.storage.value);", | |
"// console.log(response.results[0].body.storage.value);", | |
"});" | |
], | |
"type": "text/javascript" | |
} | |
} | |
], | |
"request": { | |
"auth": { | |
"type": "basic", | |
"basic": [ | |
{ | |
"key": "password", | |
"value": "{{jira_token}}", | |
"type": "string" | |
}, | |
{ | |
"key": "username", | |
"value": "{{jira_user}}", | |
"type": "string" | |
} | |
] | |
}, | |
"method": "GET", | |
"header": [ | |
{ | |
"key": "Authorization", | |
"type": "text", | |
"value": "Bearer ", | |
"warning": "This is a duplicate header and will be overridden by the Authorization header generated by Postman.", | |
"disabled": true | |
}, | |
{ | |
"key": "Accept", | |
"type": "text", | |
"value": "application/json" | |
}, | |
{ | |
"key": "Content-Type", | |
"type": "text", | |
"value": "application/json" | |
} | |
], | |
"url": { | |
"raw": "https://{{jira_host}}/wiki/rest/api/content/search?expand=body.storage,metadata.properties,history.nextVersion,version,metadata.labels,space&cql=title=\"{{templatePage}}\" and space=SEC and type=page", | |
"protocol": "https", | |
"host": [ | |
"{{jira_host}}" | |
], | |
"path": [ | |
"wiki", | |
"rest", | |
"api", | |
"content", | |
"search" | |
], | |
"query": [ | |
{ | |
"key": "expand", | |
"value": "body.storage,metadata.properties,history.nextVersion,version,metadata.labels,space" | |
}, | |
{ | |
"key": "cql", | |
"value": "title=\"{{templatePage}}\" and space=SEC and type=page" | |
} | |
] | |
} | |
}, | |
"response": [] | |
}, | |
{ | |
"name": "get users", | |
"event": [ | |
{ | |
"listen": "test", | |
"script": { | |
"exec": [ | |
"pm.test ('Processing user details',function (){", | |
" if (pm.response.code === 200){ ", | |
" console.log(\"get in 200 status\")", | |
" const moment = require('moment');", | |
" var response = pm.response.json();", | |
" pm.variables.set(\"users\",response.result);", | |
" pm.variables.set(\"user_index\",0);", | |
" pm.variables.set(\"updateid\",moment(new Date()).format(\"YYYYMMDD-hhmm\"));", | |
" var pagePrefix = pm.variables.get(\"pagePrefix\");", | |
" pm.variables.set(\"pageName\",pagePrefix+\":\"+response.result[0].username);", | |
" postman.setNextRequest(\"search for confluence page\");", | |
" } else {", | |
" console.log('get in else')", | |
" postman.setNextRequest(null);", | |
" pm.expect.fail(\"Need to get a new token\");", | |
" ", | |
" }", | |
"", | |
"});" | |
], | |
"type": "text/javascript" | |
} | |
} | |
], | |
"request": { | |
"method": "GET", | |
"header": [ | |
{ | |
"key": "Authorization", | |
"value": "Bearer {{sendgrid_api_key}}", | |
"type": "text" | |
} | |
], | |
"url": { | |
"raw": "https://api.sendgrid.com/v3/teammates", | |
"protocol": "https", | |
"host": [ | |
"api", | |
"sendgrid", | |
"com" | |
], | |
"path": [ | |
"v3", | |
"teammates" | |
] | |
} | |
}, | |
"response": [] | |
}, | |
{ | |
"name": "search for confluence page", | |
"event": [ | |
{ | |
"listen": "test", | |
"script": { | |
"exec": [ | |
" pm.test('Determining workflow:create or update page', function () {", | |
" const moment = require('moment');", | |
" const active_status = \"<ac:structured-macro ac:name=\\\"status\\\" ac:schema-version=\\\"1\\\"><ac:parameter ac:name=\\\"title\\\">active</ac:parameter><ac:parameter ac:name=\\\"colour\\\">Green</ac:parameter></ac:structured-macro>\"", | |
" var response = pm.response.json();", | |
" html = pm.variables.get(\"templatebody\");", | |
" objkeys = [\"email\",\"status\",\"extractedDate\",\"username\", \"last_name\",\"first_name\",\"is_admin\",\"is_sso\",\"user_type\"];", | |
"// console.log(html)", | |
" users = pm.variables.get(\"users\")", | |
" userIndex = pm.variables.get(\"user_index\");", | |
"// console.log(users);", | |
" if (Array.isArray(response.results) && !response.results.length){", | |
" //no result or search for this -> page found. Create page", | |
" postman.setNextRequest(\"create confluence page\");", | |
" console.log('No page exists! Create new page. Number of results: '+response.results.length);", | |
" } else if(Array.isArray(response.results) && response.results.length == 1) {", | |
" //one result or search for this page found. Go update", | |
" postman.setNextRequest(\"update confluence page\");", | |
" console.log('Found a page! Update existing page'+response.results.length);", | |
" pm.environment.set(\"pageid\", response.results[0].id);", | |
" pm.environment.set(\"version_number\", response.results[0].version.number +1);", | |
" } else {", | |
" //error condition no action", | |
" console.log('search turned up multiple results. This is not expected'+response.result.length);", | |
" }", | |
" //var itrobj = pm.iterationData.toObject();", | |
" users[userIndex].extractedDate = \"<time datetime=\\\"\"+moment(new Date()).format(\"YYYY-MM-DD\")+\"\\\"/>\"", | |
" users[userIndex].status = active_status", | |
" users[userIndex].id = users[userIndex].username", | |
" objkeys.forEach(function (tblkey) {", | |
"// This regex expects to find a value in an html table since I'm generating these pages from the HTML above, this is a good assumption", | |
"// console.log('Working on key: '+tblkey);", | |
" var regexr = new RegExp('(<strong>'+tblkey+'<\\/strong><\\/p><\\/th><td>)(.*?)(<\\/td>)');", | |
"// console.log('regexi value: '+regexr);", | |
"// console.log('Replacing with value: '+users[userIndex].tblkey);", | |
" var myvalue = _.get(users[userIndex],'.'+tblkey)", | |
"// console.log(\"myvalue set to: \"+myvalue)", | |
" if (myvalue !== undefined ) {", | |
"// console.log('Replacing with value: '+myvalue);", | |
" if (typeof myvalue === 'string' && myvalue !== 'null') {", | |
"// console.log('in test if value is string')", | |
" myvalue = myvalue.replace(/&/g,'&')", | |
"// console.log('Replacing with sanitized value: '+myvalue);", | |
" } ", | |
" html = html.replace(regexr,\"$1\"+myvalue+\"$3\");", | |
"// console.log(html);", | |
" } else {", | |
"// console.log('Table key does not exist in object! Tblkey: '+tblkey);", | |
" }", | |
" });", | |
" var emailnew = \"email_not_set\"", | |
"// console.log(\"checking if email attribute exists\")", | |
" if(users[userIndex].email !== 'null' && users[userIndex].email !== \"\" && typeof users[userIndex].email === 'string' ) {", | |
" console.log(\"Checking for weird characters in email address\")", | |
" var weirdchars = users[userIndex].email.match(/[&;]/);", | |
" console.log(\"Weird characters:\"+weirdchars)", | |
" if (weirdchars === null ){", | |
" emailnew = users[userIndex]['email'].replace(/\\./g,\"_\");", | |
" console.log(\"new label: \"+emailnew)", | |
" emailnew = emailnew.replace(/@/g,\"-\");", | |
" console.log(\"new label: \"+emailnew);", | |
" }", | |
" }", | |
" pm.environment.set(\"emailnew\", emailnew);", | |
" pm.environment.set(\"body\",JSON.stringify(html));", | |
"});" | |
], | |
"type": "text/javascript" | |
} | |
}, | |
{ | |
"listen": "prerequest", | |
"script": { | |
"exec": [ | |
"" | |
], | |
"type": "text/javascript" | |
} | |
} | |
], | |
"request": { | |
"auth": { | |
"type": "basic", | |
"basic": [ | |
{ | |
"key": "password", | |
"value": "{{jira_token}}", | |
"type": "string" | |
}, | |
{ | |
"key": "username", | |
"value": "{{jira_user}}", | |
"type": "string" | |
} | |
] | |
}, | |
"method": "GET", | |
"header": [ | |
{ | |
"key": "Authorization", | |
"type": "text", | |
"value": "Bearer ", | |
"warning": "This is a duplicate header and will be overridden by the Authorization header generated by Postman.", | |
"disabled": true | |
}, | |
{ | |
"key": "Accept", | |
"type": "text", | |
"value": "application/json" | |
}, | |
{ | |
"key": "Content-Type", | |
"type": "text", | |
"value": "application/json" | |
} | |
], | |
"url": { | |
"raw": "https://{{jira_host}}/wiki/rest/api/content/search?expand=body.storage,metadata.properties,history.nextVersion,version,metadata.labels,space&cql=title=\"{{pageName}}\" and space=SEC and type=page", | |
"protocol": "https", | |
"host": [ | |
"{{jira_host}}" | |
], | |
"path": [ | |
"wiki", | |
"rest", | |
"api", | |
"content", | |
"search" | |
], | |
"query": [ | |
{ | |
"key": "expand", | |
"value": "body.storage,metadata.properties,history.nextVersion,version,metadata.labels,space" | |
}, | |
{ | |
"key": "cql", | |
"value": "title=\"{{pageName}}\" and space=SEC and type=page" | |
} | |
] | |
} | |
}, | |
"response": [] | |
}, | |
{ | |
"name": "create confluence page", | |
"event": [ | |
{ | |
"listen": "test", | |
"script": { | |
"exec": [ | |
"pm.test ('Create user page in confluence',function (){", | |
" if(pm.response.code == '200') {", | |
" console.log(\"Created page\")", | |
" users = pm.variables.get(\"users\");", | |
" userIndex = pm.variables.get(\"user_index\");", | |
" var pagePrefix = pm.variables.get(\"pagePrefix\")", | |
"// pm.variables.set(\"pageName\",\"LookerUser:\"+response[0].id);", | |
" console.log(users.length);", | |
" console.log(userIndex)", | |
"// if( userIndex < users.length) {", | |
" if( userIndex < users.length -1 ) {", | |
" console.log(\"Setup next iteration\");", | |
" postman.setNextRequest(\"search for confluence page\");", | |
" userIndex++;", | |
" console.log('Iteration number: '+userIndex)", | |
" pm.variables.set(\"pageName\",pagePrefix+\":\"+users[userIndex].username);", | |
" pm.variables.set(\"user_index\",userIndex)", | |
" } else {", | |
"// postman.setNextRequest(\"search jira existing issues\");", | |
" setTimeout(function(){},3000)", | |
" postman.setNextRequest(\"search for confluence pages without label\");", | |
" }", | |
" }", | |
"// postman.setNextRequest(null);", | |
"});" | |
], | |
"type": "text/javascript" | |
} | |
}, | |
{ | |
"listen": "prerequest", | |
"script": { | |
"exec": [ | |
"" | |
], | |
"type": "text/javascript" | |
} | |
} | |
], | |
"request": { | |
"auth": { | |
"type": "basic", | |
"basic": [ | |
{ | |
"key": "password", | |
"value": "{{jira_token}}", | |
"type": "string" | |
}, | |
{ | |
"key": "username", | |
"value": "{{jira_user}}", | |
"type": "string" | |
} | |
] | |
}, | |
"method": "POST", | |
"header": [ | |
{ | |
"key": "Authorization", | |
"type": "text", | |
"value": "Bearer ", | |
"warning": "This is a duplicate header and will be overridden by the Authorization header generated by Postman.", | |
"disabled": true | |
}, | |
{ | |
"key": "Accept", | |
"type": "text", | |
"value": "application/json" | |
}, | |
{ | |
"key": "Content-Type", | |
"type": "text", | |
"value": "application/json" | |
} | |
], | |
"body": { | |
"mode": "raw", | |
"raw": "{\n\t\"space\": {\n\t\t\"key\": \"SEC\"\n\t},\n\t\"title\":\"{{pageName}}\",\n\t\"type\":\"page\",\n\t\"ancestors\":[{\n\t\t\"type\":\"page\",\n\t\t\"id\":\"{{ancestors_id}}\"\n\t}],\n\t\"body\": {\n\t\t\"storage\": {\n\t\t\t\"value\": {{body}},\n\t\t\t\"representation\":\"storage\"\n\t\t}\n\t},\n\t\"metadata\": {\n\t \"labels\":[{\n\t\t\t\"name\": \"{{vendor}}\"\n }, {\n\t\t \"name\": \"{{emailnew}}\"\n }, {\n\t\t \"name\": \"{{updateid}}\"\n\t\t}, {\n\t\t \"name\": \"UserAccount\"\n\t\t}],\n \"properties\": {\n \"editor\": {\n \"value\": \"v2\"\n }\n }\n\t}\n}" | |
}, | |
"url": { | |
"raw": "https://{{jira_host}}/wiki/rest/api/content", | |
"protocol": "https", | |
"host": [ | |
"{{jira_host}}" | |
], | |
"path": [ | |
"wiki", | |
"rest", | |
"api", | |
"content" | |
] | |
} | |
}, | |
"response": [] | |
}, | |
{ | |
"name": "update confluence page", | |
"event": [ | |
{ | |
"listen": "prerequest", | |
"script": { | |
"exec": [ | |
"" | |
], | |
"type": "text/javascript" | |
} | |
}, | |
{ | |
"listen": "test", | |
"script": { | |
"exec": [ | |
"pm.test ('Create user page in confluence',function (){", | |
" if(pm.response.code == '200') {", | |
" console.log(\"Created page\")", | |
" users = pm.variables.get(\"users\");", | |
" userIndex = pm.variables.get(\"user_index\");", | |
" var pagePrefix = pm.variables.get(\"pagePrefix\")", | |
"// pm.variables.set(\"pageName\",\"LookerUser:\"+response[0].username);", | |
" console.log(users.length);", | |
" console.log(userIndex)", | |
"// if( userIndex < users.length) {", | |
" if( userIndex < users.length -1 ) {", | |
" console.log(\"Setup next iteration\");", | |
" postman.setNextRequest(\"search for confluence page\");", | |
" userIndex++;", | |
" console.log('Iteration number: '+userIndex)", | |
" pm.variables.set(\"pageName\",pagePrefix+\":\"+users[userIndex].username);", | |
" pm.variables.set(\"user_index\",userIndex)", | |
" } else {", | |
"// postman.setNextRequest(\"search jira existing issues\");", | |
" setTimeout(function(){},3000);", | |
" postman.setNextRequest(\"search for confluence pages without label\");", | |
" }", | |
" }", | |
"// postman.setNextRequest(null);", | |
"});" | |
], | |
"type": "text/javascript" | |
} | |
} | |
], | |
"request": { | |
"auth": { | |
"type": "basic", | |
"basic": [ | |
{ | |
"key": "password", | |
"value": "{{jira_token}}", | |
"type": "string" | |
}, | |
{ | |
"key": "username", | |
"value": "{{jira_user}}", | |
"type": "string" | |
} | |
] | |
}, | |
"method": "PUT", | |
"header": [ | |
{ | |
"key": "Accept", | |
"type": "text", | |
"value": "application/json" | |
}, | |
{ | |
"key": "Content-Type", | |
"type": "text", | |
"value": "application/json" | |
}, | |
{ | |
"key": "User-Agent", | |
"value": "blah", | |
"type": "text", | |
"disabled": true | |
} | |
], | |
"body": { | |
"mode": "raw", | |
"raw": "{\n\t\"id\": {{pageid}},\n\t\"version\": {\n\t\t\"number\":{{version_number}}\n\t},\n\t\"type\":\"page\",\n\t\"title\":\"{{pageName}}\",\n\t\"body\": {\n\t\t\"storage\": {\n\t\t\t\"value\":{{body}},\n\t\t\t\"representation\":\"storage\"\n\t\t}\n\t},\n\t\"metadata\": {\n\t \"labels\":[{\n\t\t\t\"name\": \"{{vendor}}\"\n }, {\n\t\t \"name\": \"{{emailnew}}\"\n }, {\n\t\t \"name\": \"{{updateid}}\"\n\t\t}, {\n\t\t \"name\": \"UserAccount\"\n\t\t}],\n \"content-appearance-draft\": {\n \"value\": \"full-width\"\n },\n \"content-appearance-published\": {\n \"value\": \"full-width\"\n }\n\t}\n}" | |
}, | |
"url": { | |
"raw": "https://{{jira_host}}/wiki/rest/api/content/{{pageid}}", | |
"protocol": "https", | |
"host": [ | |
"{{jira_host}}" | |
], | |
"path": [ | |
"wiki", | |
"rest", | |
"api", | |
"content", | |
"{{pageid}}" | |
] | |
} | |
}, | |
"response": [] | |
}, | |
{ | |
"name": "search for confluence pages without label", | |
"event": [ | |
{ | |
"listen": "prerequest", | |
"script": { | |
"exec": [ | |
"" | |
], | |
"type": "text/javascript" | |
} | |
}, | |
{ | |
"listen": "test", | |
"script": { | |
"exec": [ | |
" pm.test('Determining workflow:create or update page', function () {", | |
" var response = pm.response.json().results;", | |
" pm.variables.set(\"pages\",response);", | |
" pm.variables.set(\"page_index\",0);", | |
" console.log(response);", | |
" if (Array.isArray(response) && !response.length){", | |
" //no result or search for this -> page found. Create page", | |
" console.log('No pages Found! Exiting: '+response.length);", | |
" postman.setNextRequest(null);", | |
" } else {", | |
" //error condition no action", | |
" pm.variables.set(\"pageid\",response[0].id);", | |
" console.log('Updating pages: '+response.length+' with new tag and inactive field');", | |
" }", | |
"", | |
"});" | |
], | |
"type": "text/javascript" | |
} | |
} | |
], | |
"request": { | |
"auth": { | |
"type": "basic", | |
"basic": [ | |
{ | |
"key": "password", | |
"value": "{{jira_token}}", | |
"type": "string" | |
}, | |
{ | |
"key": "username", | |
"value": "{{jira_user}}", | |
"type": "string" | |
} | |
] | |
}, | |
"method": "GET", | |
"header": [ | |
{ | |
"key": "Authorization", | |
"type": "text", | |
"value": "Bearer ", | |
"warning": "This is a duplicate header and will be overridden by the Authorization header generated by Postman.", | |
"disabled": true | |
}, | |
{ | |
"key": "Accept", | |
"type": "text", | |
"value": "application/json" | |
}, | |
{ | |
"key": "Content-Type", | |
"type": "text", | |
"value": "application/json" | |
} | |
], | |
"url": { | |
"raw": "https://{{jira_host}}/wiki/rest/api/content/search?cql=label=useraccount and label={{vendor}} and space=SEC and type=page and (label NOT IN( \"{{updateid}}\") and label NOT IN(inactive))", | |
"protocol": "https", | |
"host": [ | |
"{{jira_host}}" | |
], | |
"path": [ | |
"wiki", | |
"rest", | |
"api", | |
"content", | |
"search" | |
], | |
"query": [ | |
{ | |
"key": "cql", | |
"value": "label=useraccount and label={{vendor}} and space=SEC and type=page and (label NOT IN( \"{{updateid}}\") and label NOT IN(inactive))" | |
} | |
] | |
} | |
}, | |
"response": [] | |
}, | |
{ | |
"name": "get confluence page", | |
"event": [ | |
{ | |
"listen": "prerequest", | |
"script": { | |
"exec": [ | |
"" | |
], | |
"type": "text/javascript" | |
} | |
}, | |
{ | |
"listen": "test", | |
"script": { | |
"exec": [ | |
" pm.test('Determining workflow:create or update page', function () {", | |
" var response = pm.response.json();", | |
" const moment = require('moment');", | |
" const deactivated_status = \"<ac:structured-macro ac:name=\\\"status\\\" ac:schema-version=\\\"1\\\"><ac:parameter ac:name=\\\"title\\\">deactivated</ac:parameter><ac:parameter ac:name=\\\"colour\\\">Red</ac:parameter></ac:structured-macro>\"", | |
" var html = response.body.storage.value", | |
" var regexr = new RegExp('(<strong>'+\"status\"+'<\\/strong><\\/p><\\/th><td>)(.*?)(<\\/td>)');", | |
" html = html.replace(regexr,\"$1\"+deactivated_status+\"$3\");", | |
" pm.variables.set(\"pageName\",response.title);", | |
" console.log(response.title);", | |
" console.log(response.id);", | |
" console.log(pm.environment.get(\"pageName\"));", | |
" pm.variables.set(\"pageid\", response.id);", | |
" pm.variables.set(\"version_number\", response.version.number +1);", | |
" pm.variables.set(\"body\",JSON.stringify(html));", | |
"});" | |
], | |
"type": "text/javascript" | |
} | |
} | |
], | |
"request": { | |
"auth": { | |
"type": "basic", | |
"basic": [ | |
{ | |
"key": "password", | |
"value": "{{jira_token}}", | |
"type": "string" | |
}, | |
{ | |
"key": "username", | |
"value": "{{jira_user}}", | |
"type": "string" | |
} | |
] | |
}, | |
"method": "GET", | |
"header": [ | |
{ | |
"key": "Authorization", | |
"type": "text", | |
"value": "Bearer ", | |
"warning": "This is a duplicate header and will be overridden by the Authorization header generated by Postman.", | |
"disabled": true | |
}, | |
{ | |
"key": "Accept", | |
"type": "text", | |
"value": "application/json" | |
}, | |
{ | |
"key": "Content-Type", | |
"type": "text", | |
"value": "application/json" | |
} | |
], | |
"url": { | |
"raw": "https://{{jira_host}}/wiki/rest/api/content/{{pageid}}?expand=body.storage,metadata.properties,history.nextVersion,version,metadata.labels,space", | |
"protocol": "https", | |
"host": [ | |
"{{jira_host}}" | |
], | |
"path": [ | |
"wiki", | |
"rest", | |
"api", | |
"content", | |
"{{pageid}}" | |
], | |
"query": [ | |
{ | |
"key": "expand", | |
"value": "body.storage,metadata.properties,history.nextVersion,version,metadata.labels,space" | |
} | |
] | |
} | |
}, | |
"response": [] | |
}, | |
{ | |
"name": "add label to page", | |
"event": [ | |
{ | |
"listen": "prerequest", | |
"script": { | |
"exec": [ | |
"" | |
], | |
"type": "text/javascript" | |
} | |
}, | |
{ | |
"listen": "test", | |
"script": { | |
"exec": [ | |
" pm.test('Determining workflow:create or update page', function () {", | |
" var response = pm.response.json();", | |
" console.log(response)", | |
"});" | |
], | |
"type": "text/javascript" | |
} | |
} | |
], | |
"request": { | |
"auth": { | |
"type": "basic", | |
"basic": [ | |
{ | |
"key": "password", | |
"value": "{{jira_token}}", | |
"type": "string" | |
}, | |
{ | |
"key": "username", | |
"value": "{{jira_user}}", | |
"type": "string" | |
} | |
] | |
}, | |
"method": "POST", | |
"header": [ | |
{ | |
"key": "Authorization", | |
"type": "text", | |
"value": "Bearer ", | |
"warning": "This is a duplicate header and will be overridden by the Authorization header generated by Postman.", | |
"disabled": true | |
}, | |
{ | |
"key": "Accept", | |
"type": "text", | |
"value": "application/json" | |
}, | |
{ | |
"key": "Content-Type", | |
"type": "text", | |
"value": "application/json" | |
} | |
], | |
"body": { | |
"mode": "raw", | |
"raw": "{\n \"name\":\"inactive\"\n}" | |
}, | |
"url": { | |
"raw": "https://{{jira_host}}/wiki/rest/api/content/{{pageid}}/label", | |
"protocol": "https", | |
"host": [ | |
"{{jira_host}}" | |
], | |
"path": [ | |
"wiki", | |
"rest", | |
"api", | |
"content", | |
"{{pageid}}", | |
"label" | |
] | |
} | |
}, | |
"response": [] | |
}, | |
{ | |
"name": "update confluence page user status", | |
"event": [ | |
{ | |
"listen": "prerequest", | |
"script": { | |
"exec": [ | |
"" | |
], | |
"type": "text/javascript" | |
} | |
}, | |
{ | |
"listen": "test", | |
"script": { | |
"exec": [ | |
"pm.test ('Create user page in confluence',function (){", | |
" if(pm.response.code == '200') {", | |
" console.log(\"Updated page: \"+pm.variables.get(\"pageName\"))", | |
" pages = pm.variables.get(\"pages\");", | |
" pageIndex = pm.variables.get(\"page_index\");", | |
" var pagePrefix = pm.variables.get(\"pagePrefix\")", | |
" if( pageIndex < pages.length -1 ) {", | |
" console.log(\"Setup next iteration\");", | |
" postman.setNextRequest(\"get confluence page\");", | |
" pageIndex++;", | |
" console.log('Iteration number: '+pageIndex)", | |
" pm.variables.set(\"pageid\",pages[pageIndex].id);", | |
" pm.variables.set(\"page_index\",pageIndex)", | |
" } else {", | |
"// postman.setNextRequest(\"search jira existing issues\");", | |
" postman.setNextRequest(null);", | |
" }", | |
" }", | |
"// postman.setNextRequest(null);", | |
"});" | |
], | |
"type": "text/javascript" | |
} | |
} | |
], | |
"request": { | |
"auth": { | |
"type": "basic", | |
"basic": [ | |
{ | |
"key": "password", | |
"value": "{{jira_token}}", | |
"type": "string" | |
}, | |
{ | |
"key": "username", | |
"value": "{{jira_user}}", | |
"type": "string" | |
} | |
] | |
}, | |
"method": "PUT", | |
"header": [ | |
{ | |
"key": "Accept", | |
"type": "text", | |
"value": "application/json" | |
}, | |
{ | |
"key": "Content-Type", | |
"type": "text", | |
"value": "application/json" | |
}, | |
{ | |
"key": "User-Agent", | |
"value": "blah", | |
"type": "text", | |
"disabled": true | |
} | |
], | |
"body": { | |
"mode": "raw", | |
"raw": "{\n\t\"id\": {{pageid}},\n\t\"version\": {\n\t\t\"number\":{{version_number}}\n\t},\n\t\"type\":\"page\",\n\t\"title\":\"{{pageName}}\",\n\t\"body\": {\n\t\t\"storage\": {\n\t\t\t\"value\":{{body}},\n\t\t\t\"representation\":\"storage\"\n\t\t}\n\t}\n}" | |
}, | |
"url": { | |
"raw": "https://{{jira_host}}/wiki/rest/api/content/{{pageid}}", | |
"protocol": "https", | |
"host": [ | |
"{{jira_host}}" | |
], | |
"path": [ | |
"wiki", | |
"rest", | |
"api", | |
"content", | |
"{{pageid}}" | |
] | |
} | |
}, | |
"response": [] | |
} | |
], | |
"event": [ | |
{ | |
"listen": "prerequest", | |
"script": { | |
"type": "text/javascript", | |
"exec": [ | |
"" | |
] | |
} | |
}, | |
{ | |
"listen": "test", | |
"script": { | |
"type": "text/javascript", | |
"exec": [ | |
"" | |
] | |
} | |
} | |
], | |
"variable": [ | |
{ | |
"key": "templatePage", | |
"value": "UAT:Sendgrid" | |
}, | |
{ | |
"key": "ancestors_id", | |
"value": "2716041466" | |
}, | |
{ | |
"key": "pagePropertiesName", | |
"value": "userAccount" | |
}, | |
{ | |
"key": "pagePrefix", | |
"value": "SendgridUser" | |
}, | |
{ | |
"key": "sendgrid_api_key", | |
"value": "" | |
}, | |
{ | |
"key": "vendor", | |
"value": "SendGrid" | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment