I have the following Google Script that works when executed from a GoogleSheet
function CreateIncident() {
var username = "user";
var password = "Password";
var UserCredentials = "Basic " + Utilities.base64Encode(username + ":" + password)
var IssueURL = "https://xxxx.service-now.com/api/now/v2/table/incident";
var IssueData = {
'short_description':'Description Goes Here',
'priority':'3',
'type':'Normal',
'assignment_group':'Group Goes Here',
};
// Call the API
var payload = JSON.stringify(IssueData);
var headers = { "Accept":"application/json",
"Content-Type":"application/json",
"Authorization": UserCredentials,
};
var options = { "method":"POST",
"headers": headers,
"payload" : payload
};
var response = UrlFetchApp.fetch(IssueURL, options);
if (response.getResponseCode() == 401) {
Browser.msgBox("Error retrieving data for URL" + IssueURL + ":" + response.getResponseCode() + ":" + response.getContentText());
return "";
}
//
// Parse the JSON response to use the Issue Key returned by the API in the email
//
var dataAll = JSON.parse(response.getContentText());
var issueKey = dataAll.number
}How would this be written in SIL, so that it would execute in Power Script ?