Hello,
I'm trying to get the email address of project leads (owners) by using their account ID in a python script. The problem that I'm having is that I get a 401:
{'code': 401, 'message': 'Unauthorized; scope does not match'}So what I do is I start iterating over the project (space) roles by getting the roles using this URL (I use the tenant ID in the url, given that this is a scoped token):
roles_url = f"https://api.atlassian.com/ex/jira/{tenant_id}/rest/api/3/project/{project_key}/role/
I access the project data using this url:
proj_url = f"https://api.atlassian.com/ex/jira/{tenant_id}/rest/api/3/project/{project_key}"
So I have a 'lead' dictionary key and a so-called 'accountId' key within this 'lead' dictionary.
So the next thing I do is try to retrieve the email address of this account ID, but it seems that this token is not authorized or I'm not querying it correctly. The URL I'm using is:
user_email_url = f"https://api.atlassian.com/ex/jira/{tenant_id}/rest/api/3/user/email"
To which I'm sending the lead accountID:
query = { 'accountId': proj_data['lead']['accountId']}The token permissions are:
read:account
read:jira-user
read:jira-work
Any ideas why this might not work?
It worked eventually by this url instead:
https://api.atlassian.com/ex/jira/{tenant_id}/rest/api/3/user/
(without 'email') at the end and simply getting the 'emailAddress' key. I don't really understand why it works only this way and the 'email' URL doesn't, given the API docs here: https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-users/#api-rest-api-3-user-email-get
But it's fine as long as it works :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.