1

I am new to Jira and I want to get all the dashboards of a user.

So I go through the link and got that by this /rest/api/3/dashboard URL I can find all the dashboards and also got one more point that Apps cannot access this REST resource.

Right now I have created Jira platform REST API APP and using its client_id and getting access_token by Auth 2.0 (3LO) but by this authentication process, I am not getting the all dashboard.

Is there any other authentication process I have to follow to get all dashboard as it is mentioned Apps cannot access this REST resource? please help me.

Thanks

lazyCoder
  • 2,544
  • 3
  • 22
  • 41
  • 1
    Have you tried basic auth? You need to supply your email paired with your API token as password. Do note that your API token can be generated by following [this](https://confluence.atlassian.com/cloud/api-tokens-938839638.html) – Ian Nov 22 '19 at 05:32
  • I have to authenticate a user with rest but in this case, how can I generate this token with REST means here user is creating his own token from his account – lazyCoder Nov 22 '19 at 11:02

1 Answers1

0

in my case,rest/api/3 not work, I use rest/api/2 instead.

import requests
from requests.auth import HTTPBasicAuth
import json

def auth(name, password):
    return HTTPBasicAuth(name, password)

def get_dashboard(auth, id):

    url = f"https://jira.xxx.com/rest/api/2/dashboard/{id}"
    headers = {
        "Accept": "application/json"
    }
    response = requests.request(
        "GET",
        url,
        headers=headers,
        auth=auth
    )

    print(response.json())

then call this fuction:

auth = auth("username", "password")
get_all_dashboard(auth, 20)

it returns 20 dashboard now.

{
'startAt': 0,
'maxResults': 20,
'total': 811,
'next': 'https://jira.xxxxx.com/rest/api/2/dashboard?maxResults=2&startAt=2',
'dashboards': [{
    'id': '10943',
    'name': 'qqqqq',
    'self': 'https://jira.xxxxx.com/rest/api/2/dashboard/10943',
    'view': 'https://jira.xxxxx.com/secure/Dashboard.jspa?selectPageId=10943'
}, {
    'id': '10953',
    'name': 'wwwww',
    'self': 'https://jira.xxxxx.com/rest/api/2/dashboard/10953',
    'view': 'https://jira.xxxxx.com/secure/Dashboard.jspa?selectPageId=10953'
}]
}
nicole
  • 1
  • 2