I have written the following script to get content from a Jira url:
function getIssue() {
var encoded = Utilities.base64Encode("script_token:xxxxx");
var headers = {
'Authorization': 'Basic '.concat(encoded)
};
var options = {
'headers': headers
};
// logs for debug
var response = UrlFetchApp.getRequest("http://<jira_domain>/rest/api/2/issue/ISSUE-1234", options);
for(i in response) {
Logger.log(i + ": " + response[i]);
}
Logger.log(JSON.stringify(response))
// Fetch from Jira
var response = UrlFetchApp.fetch("http://<jira_domain>/rest/api/2/issue/ISSUE-1234", options);
Logger.log(response.getContentText());
}
This fail, the error is the the url is not reachable.
I tried the cUrl:
curl -L -D- \
-X GET \
-H "Authorization: Basic <encoded>" \
-H "Content-Type: application/json" \
"http://<jira_domain>/rest/api/2/issue/ISSUE-1234"
The cUrl is returning as expected.
In the logs, I get:
[19-04-24 12:34:39:462 PDT] headers: [object Object]
[19-04-24 12:34:39:463 PDT] method: get
[19-04-24 12:34:39:463 PDT] payload:
[19-04-24 12:34:39:464 PDT] followRedirects: true
[19-04-24 12:34:39:464 PDT] validateHttpsCertificates: true
[19-04-24 12:34:39:465 PDT] useIntranet: false
[19-04-24 12:34:39:466 PDT] contentType: null
[19-04-24 12:34:39:466 PDT] url: http://<jira_domain>/rest/api/2/issue/ISSUE-1234
[19-04-24 12:34:39:467 PDT] {"headers":{"Authorization":"Basic <encoded>"},"method":"get","payload":"","followRedirects":true,"validateHttpsCertificates":true,"useIntranet":false,"contentType":null,"url":"http://<jira_domain>/rest/api/2/issue/ISSUE-1234"}