Skip to main content

Is there any way to list the teams a user is a part of using REST API ?


Forum|alt.badge.img+1

I have a requirement to fetch the list of teams a user is a part of

Please help on how I can achieve this? 

Was it helpful?

12 replies

Addison Schultz
Mironeer

There isn’t an endpoint that does this for you, but you are able to get a list of teams in an organization, and then search the teams for their members, and filter out your user from there

 

https://developers.miro.com/reference/getteams

 

Please keep in mind, that these APIs require an active enterprise plan in order to work.


Forum|alt.badge.img+1

Hi @Addison Schultz 

The response of this does not have team members in it. Is there any other alternative?


Addison Schultz
Mironeer

@HarshitaVishwakarma Is organization using the enterprise plan?


Forum|alt.badge.img+1

Yes. I am able to list the teams, and get the team by it’s id but the response does not have team members in it. 


Addison Schultz
Mironeer

After you get the teamId, you will then need to call this endpoint to get users of that team: https://developers.miro.com/reference/getmembers


Forum|alt.badge.img+1

Got it. But unfortunately there is a limit of returning only 100 teams in the list teams API whereas I am dealing with 100+ teams. Is there any way to overcome this?

On a side-note the solution you provided looks good but seems like it will take a lot of looping and iterations to achieve it, especially when the data is huge. What are your thoughts on this?


Addison Schultz
Mironeer

 

You can set one of the parameters that should return more than 100 teams. Regarding the looping over data - this is the recommend way you should approach this

 


Forum|alt.badge.img+1

Okay thanks. And I tried setting the limit to 200 but I get back this error: 

{

    "status": 400,

    "code": "invalidParameter",

    "message": "org.springframework.validation.BeanPropertyBindingResult: 1 errors\nField error in object 'teamsCursorQuery' on field 'limit': rejected value [200]; codes [Max.teamsCursorQuery.limit,Max.limit,Max.int,Max]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [teamsCursorQuery.limit,limit]; arguments []; default message [limit],100]; default message [limit value should be less than 100]",

    "type": "error"

}

Seems like the docs don’t mention that 100 is the max limit. 


Addison Schultz
Mironeer

Thanks for reporting - this is a bug in our docs, I’ll pass it over to our team. 

That being said, are you able to use the cursor parameter to find the next item(s) in the iteration?


Forum|alt.badge.img+1

No problem. I tried the cursor parameter and it works. Just so my understanding isn’t wrong, so adding the cursor like this:

https://api.miro.com/v2/orgs/<org_id>/teams?limit=100&cursor=<100th team’s ID>

will return the next 100 teams based on the 100th team’s id and so on, correct?

P.S: There’s another bug in the docs for this API

Should be: https://api.miro.com/v1/oauth-token

Currently it is: https://api.miro.com/v1/v1/oauth-token


Addison Schultz
Mironeer

Yes, that is correct!


Forum|alt.badge.img+1

Great! Thanks so much for your help. I really appreciate it 🙂


Reply