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


Badge

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

Please help on how I can achieve this? 


12 replies

Userlevel 4

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.

Badge

Hi @Addison Schultz 

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

Userlevel 4

@HarshitaVishwakarma Is organization using the enterprise plan?

Badge

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. 

Userlevel 4

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

Badge

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?

Userlevel 4

 

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

 

Badge

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. 

Userlevel 4

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?

Badge

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

Userlevel 4

Yes, that is correct!

Badge

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

Reply