Hi,
I'm trying to get worklogs using REST API and I'm able to get results but when I use the same call using javascript (Google Spreadsheet scripting) despite providing user login credentials, I get a 403 instead. Is there a setting in JIRA that I need to turn on to allow me to get same results?
Thanks,
Jeff
No, there's nothing to change - you get a 403 because your code is not passing the right credentials and/or a valid REST call. We can't tell you what is wrong with your REST call without seeing it.
Thanks for the reply Nick, but I'm pretty sure I given the correct credentials. The rest call works on the browser and it work on a client JIRA cloud instance. Below is the code I use on Google Spreadsheet:
var url = "https://jira.my-domain.com/rest/api/2/mypermissions";
var x = Utilities.base64Encode("jeferson:password");
// I also tried the token generated from https://id.atlassian.com/manage/api-tokens
var headers = {
"Accept":"application/json",
"Content-Type":"application/json",
"method": "GET",
"headers": {"Authorization": "Basic " + x},
"muteHttpExceptions": true
};
var response = UrlFetchApp.fetch(url, headers); // gets a 403
var errormsg = response.getResponseCode();
var dataAll = JSON.parse(response.getContentText());
var dataSet = dataAll;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There is nothing to configure in a Jira server instance to "enable" anything. The 403 happens because your credentials for what you're asking are not valid for the system.
Sometimes, this is when you try to do something that you don't have permissions for, and sometimes, it's a network gateway/proxy/firewall that doesn't like the credentials. But mostly, it's going to be because your credentials are invalid.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Okay, thanks for replying but this still does not answer why I can get results if I access the URL straight from the browser and fails if it's from the script. I'm using the same credentials so this should not be a permission issue.
The only thing I'm thinking right now is that CAPTCHA might be triggering (I just noticed now that after the an update, my login from time to time triggers a CAPTCHA). I will ask are IT team to check if we can temporarily disable this for my user just to test if the script would work.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
All I can tell you is that there is something wrong in the script - it's not passing Jira a valid set of credentials.
But I think your Captcha instinct is almost certainly spot-on - once you've failed login a few times, you'll need to pass that test to allow login.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.