Can fetch Jira API from Terminal, but fail via Google Apps Script

Michael Rätzsch July 2, 2018

We run a self-hosted Jira-Environment and set up OAUth Access to use the REST API.

I am able to fetch any API Call via Terminal (cURL) but fail each time i will try to fetch via Google Apps Script.

I guess that there is only one simple little detail missing, but i cant find it. :(

 

This is my cURL Call:

curl -D- -X GET -H "Authorization: Basic BASE64encoded_username:passwd" -H "Content-Type: application/json" "https://JIRA-DOMAIN.de/rest/api/2/issue/ISSUE-ID"

 And this is how i would like to fetch it via Google Apps Script: 

function getAPIFeedback() {
  var header_options = {
'method':'get',
'headers':{
'Authorization':'Basic BASE64encoded_username:passwd',
'Content-Type':'application/json;charset=UTF-8'
}
};

try{
var response = UrlFetchApp.fetch('https://JIRA-DOMAIN.de/rest/api/2/issue/ISSUE-ID', header_options);
Logger.log(response);
}catch(err){Logger.log(err)}
}

Each time I get a 401 Error, and dont understand why.

 

I would be very happy if someone could help me.

Bet Regards, Michael 

3 answers

1 vote
Torsten Meringer July 5, 2018

Any chance that there is a reverse proxy involved which requires additional authentication? ;-)

Michael Rätzsch July 5, 2018

*hmm

Could be possible.
I will get in touch with my Admin and give it a try.

Thanks for your advice.

0 votes
arashbi May 21, 2021

I am having the same problem. Anyone managed to fix this?

0 votes
Alfredo Fidani September 15, 2019

Same occurred to me.

It is fixed?

There is a workaround to solve it?

Suggest an answer

Log in or Sign up to answer