...
As is shown in the example, we start with the example JSON that will be used to input.
Code Block |
---|
"properties": [
{
"key": "sd.public.comment",
"value": {
"internal": true
}
}
]
} |
|
Overview
Use the Find/Replace feature of the SIL Manager to add an escape character before every quote.
Surround each line with quotes and place a plus sign at the end.
Set the newly formatted JSON to a string variable and put a semicolon at the end.
Step 1 - Add an Escape Character before Every Quote
...
Set the entire code block to a string variable so that it can be passed into the REST endpoint.
Code Block |
---|
string updateInfo = "{" +
"\"properties\": [" +
"{" +
"\"key\": \"sd.public.comment\"," +
"\"value\": {" +
"\"internal\": true" +
"}" +
"}" +
"]" +
"}";
runnerLog(updateInfo); |
|
Step 4 - Print Output and Check for Accuracy
...
The Final Script
Below we use httpPut() to pass the "updateInfo" values to update the Service Desk value "isPublic" to false.
Code Block |
---|
string isPublic = "false";
number [] ids = getAllCommentIds(key);
number lastComment = ids[size(ids) -1];
string updateInfo = "{" +
"\"properties\": [" +
"{" +
"\"key\": \"sd.public.comment\"," +
"\"value\": {" +
"\"internal\": " + isPublic + "" +
"}" +
"}" +
"]" +
"}";
HttpRequest request;
request.headers += httpCreateHeader("Content-Type", "application/json");
request.headers += httpBasicAuthHeader("admin", "admin");
string result = httpPut("http://localhost:8080/rest/api/3/issue/" + key + "/comment/" + lastComment, request, updateInfo);
// runnerLog(result);
number statusCode = httpGetStatusCode();
if (statusCode >= 200 && statusCode < 300) {
runnerLog("SUCCESS");
}
else {
string msg = trim(statusCode) + ":" + httpGetErrorMessage() + ":" + httpGetReasonPhrase();
runnerLog(msg);
} |
|
Additional Help
Need help implementing this script? Talk to me directly to me by clicking on the bot on this page.
...