Fetch Associated Teams for the given user - Jira api for project page

I am looking for api to fetch teams list associated with the user. i tried.
BTW i am building jira project page.
Account id fetched from /myself api.

    const orgResponse = await requestJira(`/rest/api/3/organization?accountId=${accountId}`);
    const orgData = await orgResponse.json();
    const orgId = orgData.values[0].id;

Unathorized Failure. i tried scope : - read:organization:jira but this scope is not available.

once i get the org id. i think i will use

 const response = await requestJira(`gateway/api/public/teams/v1/org/${orgId}/teams`, {
      method: 'GET',
      headers: {
        'Content-Type': 'application/json',
      },
    });

    const data = await response.json();
    console.log('fetching team:', data.results);
    if (data === undefined || data?.results === undefined) {
      return [];
    }

    return data.results;

Any better api for fetching the teams.

Hello @PrakashJeganathan

There is no such Jira REST API endpoint… hence the error message.

You cannot get a user’s teams via Jira’s REST API, you must use the Teams REST API, as you’ve already discovered.

Also, you said:

i think i will use
const response = await requestJira(gateway/api/public/teams/v1/org/${orgId}/teams)

But that will not work, since Jira cannot access the Teams API, so Jira cannot ‘respond’ to that request. You’re confusing two different products and their two different APIs and their two different access paths.

Trust me, this question has been asked many times before and the answer is easily found by using a Google search or just searching this forum.

in teams rest api. we need org id. how do i fetch org id ?. I tried google first. i could not find the result i dont know how to get the org id. there is no google explaination for the same.

That’s odd. I did a Google search of ‘atlassian rest api get organization ID’ and got the answer, immediately and it was the very first result returned. Maybe you are using some other ‘Google’ where you are?

I think I’ll leave you to your own devices now.

I understood your frustration. i know this is basic questions. the issue i am facing is unauthorized. i tried multiple option. with this api for org details, it required a scope. or need to do different way. Thats y i raised a query any api as simple as fetching issues , sprints or boards.
https://www.google.com/search?q=scope+for+admin%2Fv1%2Forgs&oq=scope&gs_lcrp=EgZjaHJvbWUqBggAEEUYOzIGCAAQRRg7MhAIARAuGMcBGLEDGNEDGIAEMgYIAhBFGDsyCggDEAAYsQMYgAQyBwgEEAAYgAQyBggFEEUYPDIGCAYQRRg8MgYIBxBFGDzSAQgyMjEzajBqNKgCALACAQ&sourceid=chrome&ie=UTF-8

Once again sorry for wasting your time.

I think you’re just not taking the time to read the documentation properly and thoroughly and you’re making random guesses instead.

For example, you said for the Organization REST API “it required a scope”, but it doesn’t. That API doesn’t support OAuth, only Basic auth with a bearer token. This is stated right there on the Authentication page:

Authentication is implemented via an API key. Use the API Key as a Bearer access token to authenticate the script and manage your organization. The Organization ID is used as a unique identifier in the path parameter for the organization. Copy the Organization ID and API key and keep them in a safe place. We won’t show them to you again.

… so, in the absence of OAuth, there are no ‘scopes’ to use.

On that page, it also gives a link to follow to find the documentation that describes exactly how to generate the key to use the API and also get the Org ID:

To make requests to the API with the client/tool of your choice, Create an API key and get the organization ID.

All you have to do is actually read the documentation thoroughly.

Search this forum first; chances are your question has already been asked and answered already (trust me, it has!). Then try Google, as I’ve seen the same question many times over on the Community Forum, so Google will have indexed it.

You’re not wasting my time… you’re mostly wasting YOURS. When you learn to look for, find or work out the answers yourself, you break free of the cycle of constantly having to stop work, ask questions and then wait for someone else to give you an answer… maybe, sometime.

Have fun.