1

I have a Google Script running as part of Sheet that fetched some tickets from out Jira board using basic authentication and JQL.

The JQL works perfectly fine when run from command line via curl (ubuntu) but shows the following error when executed from Google Script -

{"errorMessages":["Field 'assignee' does not exist or this field cannot be viewed by anonymous users."],"errors":{}}

This is how I'm making the curl request -

curl -H "Authorization: Basic <base64 encoded username:password>" -X GET -H "Content-Type: application/json" https://<jira_host>.com/rest/api/2/search?jql=<JQL>

and this is how I'm doing it form Google Script -

var url = encodeURI(host + 'rest/api/2/search?jql=' + jql);
var params = {};
params['header'] = {'Authorization': PropertiesService.getUserProperties().getProperty('AUTH')};
params['Content-Type'] = 'application/json';
params['Accept'] = 'application/json';
params['method'] = 'GET';
params['muteHttpExceptions'] = true;
var response = UrlFetchApp.fetch(url, params);

I referred JIRA Basic Authentication guide's CAPTCHA section to see if I'm being denied authentication but I confirmed that this is not the case by verifying response headers.

I'm not sure what am I doing incorrectly to cause this error. Any help is appreciated.

Thanks.

2 Answers 2

2

I solved it myself. It was a typo.

params['header'] = {'Authorization': PropertiesService.getUserProperties().getProperty('AUTH')};

Fixed to

params['headers'] = {'Authorization': PropertiesService.getUserProperties().getProperty('AUTH')};

Notice that it is 'headers' not 'header'.

Sign up to request clarification or add additional context in comments.

Comments

0

The most probable answer is that the jql parameter isn't properly encoded. Switch to the POST method and try it that way.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.