Not Getting Data from Graph rest api for MS Team

Copper Contributor

Hi,

I've created an app at https://portal.azure.com/#blade/Microsoft_AAD_RegisteredApps/ApplicationsListBlade

I can do oauth using my credentials and getting token to access secure resource through it, but I'm getting empty result when i query the following api 

https://graph.microsoft.com/v1.0/teams
or
https://graph.microsoft.com/v1.0/users/{userID}/joinedTeams
though I've teams in my teams account but the response return empty result as follows

{
"value": []
}
also the second api return response below
{
"error": {
"code": "ResourceNotFound",
"message": "Resource not found.",
"innerError": {
"date": "2021-04-22T06:34:22",
"request-id": "55e3a10e-6e63-466e-a4ed-c15e2cab56b7",
"client-request-id": "f50412d2-6beb-5af8-170c-7ac4fd27c448"
}
}
}
Can you please clarify how can i get data from MS teams ? data like teams, groups, channels, chats etc using graph api.
 
Thanks.
20 Replies

Hi @hidayat3676, To list joined teams for user you need application level permissions. Please go through this documentation for more details. 

 

 

GET https://graph.microsoft.com/v1.0/users/{id}/joinedTeams

 

 

and to list channels using graph API use

 

GET https://graph.microsoft.com/v1.0/teams/{team-id}/channels

 

 

@Mamatha-MSFT Hi,

Thanks for your response

I already have these permission you can see in the image attach, plus what about my first api teams api which return empty data ?

Hi @hidayat3676, I have gone through your screenshot but few permissions are missing.  

TeamSettings.Read.All, TeamSettings.ReadWrite.All, User.Read.All, User.ReadWrite.All, Directory.ReadWrite.All

Please make sure to add these permissions and let us know if the issue still persists. 

and Get https://graph.microsoft.com/v1.0/teams is not a valid request. 

Hi @Mamatha-MSFT ,

I 've added these permissions but still no luck

firstly is it necessary to add write permission for resources that i only want to read?

2nd  if Get https://graph.microsoft.com/v1.0/teams  is invalid why it return 200 ok?

3rd no endpoint except /users, /users/{id}, /me working for me when i used post request for create a resource it return 405 and when use GET it either return empty data in some end point and on others it return 404.

Can you please explain this? 

See Attached Images for reference.

 

Thanks

Hi @hidayat3676, To get team you need to append team-id for your request. Please go through this documentation

GET https://graph.microsoft.com/v1.0/teams/{teams-id}


For GET https://graph.microsoft.com/v1.0/me/joinedTeams can you please share the error screenshot.  

As per your postman screenshot your trying to create a group  using POST https://graph.microsoft.com/v1.0/groups. I think you don't have required permissions to create a group (Group.Create, Group.ReadWrite.All, Directory.ReadWrite.All). Please go through this documentation to create a group. 

Could you please specify what exactly you want to get. So that I can guide you. 

@Mamatha-MSFT 
Thanks for your response
I already have attached my permission list ss.
Actually I'm developing a Saas based app, I want to get all teams of the organization or the account that install my app, their groups, channels, chats, installed apps and all users

Response For GET https://graph.microsoft.com/v1.0/me/joinedTeams
{
"error": {
"code": "ResourceNotFound",
"message": "Resource not found.",
"innerError": {
"date": "2021-04-26T08:18:32",
"request-id": "2264149e-2352-4d72-9dae-b22e09f1be52",
"client-request-id": "2264149e-2352-4d72-9dae-b22e09f1be52"
}
}
}
I've teams and channels in my account.
Please Guide me about how can i get the above data?


Thanks.

Hi @hidayat3676 Please follow these steps to get List joinedTeams

1. Add required permissions to get List joinedTeams

Mamatha-MSFT_1-1619522537075.png

 


2. Get Access Token

Mamatha-MSFT_0-1619522441422.png

3.  get List joinedTeams using GET https://graph.microsoft.com/v1.0/users/{id}/joinedTeams . Please see the below image. 

Mamatha-MSFT_2-1619522778080.png

 

Try these steps and let me know if the issue still persists. 

@hidayat3676 Please let us know if the issue has been resolved.

Hi @Mamatha-MSFT,

 

I'm getting teams if i do oauth using organization admin but still i'm unable to get the team channels or single team info check ss below for details.

using https://graph.microsoft.com/v1.0/teams/{team_id}

 

Can you please confirm what is the issue?

 

Thanks.

Hi @hidayat3676 To Get team, are you using application level permissions or delegated level permissions?  If your using application level permissions, the permissions marked with * use resource-specific consent. The resource specific consent permissions need to be added in manifest. 

 

Please go through the documentation. 
https://docs.microsoft.com/en-us/graph/api/team-get?view=graph-rest-1.0&tabs=http 

@Mamatha-MSFT

 

Should i manually add these RSC to manifest or it is added auto when i add permission from the permission list ?

 

Also by * you mean {resourse}.{permission}.All  ?

 

 

Hi @Mamatha-MSFT ,

 

Getting Error below when i add RSC to Manifest.json check the attach ss.

Hi @hidayat3676, Please go through this RSC sample

@Mamatha-MSFTThis is different to my already auto generated manifest.
Should i create the whole manifest manually and then upload it ?

 

Also while Searching the error i found this

https://docs.microsoft.com/en-us/graph/teams-protected-apis

should i fill the form or ignore ?

Hi @hidayat3676  Yes you need create the whole manifest manually and then upload it. Please follow the steps provided in this documentation

Get  https://graph.microsoft.com/v1.0/teams/{team_id} is not under protected API. There is no need to fill the request form. 

Hi Mamatha-MSFT,
But i also need the other end points mentioned in the protected api list should i fill form for it or it will also be resolved using the manifest ?

@hidayat3676  Yes. If you are using protected API you need to request access. Please fill the form to request access.  

@Mamatha-MSFT
Done With the form, Can you tell till when it is expected for my app to be given access to the protected Api's ?

@hidayat3676 They review access requests every Wednesday and deploy approvals every Friday.