Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Shape the future of the Fabric Community! Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions. Take survey.

Reply
jmoreyproadata
New Member

Get data from Microsoft teams (shifts)

How to connect power bi to microsoft teams, extracting information from app shifts that its use from create timetable.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hello sjb9:

 In my application I ussed an OData feed to directly query the Graph (beta) API directly into PowerBi. The data is then updated when the report is refreshed. Have not yet worked with "Flow". The user is currently refreshing the reports as needed as a short term solution. Hope this helps.

 

= OData.Feed("https://graph.microsoft.com/beta/teams/your teams ID #/schedule", null, [Implementation="2.0"])

View solution in original post

14 REPLIES 14
dansleps
New Member

Anyone managed to get data from TimeCards in shifts? (clocking in and out times).

ben3
Frequent Visitor

I have just tried:
https://graph.microsoft.com/beta/teams/#your teams ID #/schedule/timeCards

and got Expression.Error: Access to the resource is forbidden.

v-xuding-msft
Community Support
Community Support

Hi @jmoreyproadata ,

Does that make sense? If so, kindly mark my answer as the solution to close the case please. More people will benefit from here. Thanks in advance.

 

Best Regards,

Xue Ding

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. Kudos are nice too.

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-xuding-msft
Community Support
Community Support

Hi @jmoreyproadata ,

Currently, we can't get data from Teams directly in Power BI.  We only can check usage data from Teams and view report in Teams . To make Power BI better, you can submit your request at Power BI Ideas and vote it up.

 

Best Regards,

Xue Ding

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Is it possible to use the Graph API to import the shift data from TEAMS to Power BI to use as a data slicer/ filter?? This is a very typical application for manufacturing. Much needed. Is it possible? Is that the BETA of Graph has this functionality. Is there a better way

 

https://docs.microsoft.com/en-us/graph/api/schedule-list-shifts?view=graph-rest-beta&tabs=http

Anonymous
Not applicable

Update to my own question for other users. This does work. Use an "ODATA" connection to the Graph API ( beta ). Only the beta API has the shifts data. You can then expand the lists that are returned from the API. We are actually using the shifts time data to cross filter other data in PowerBi via a calculated column in DAX. 

Hi, I am able to access all other tables except time card. I get an 'access forbidden error'. Would you mind telling what permission levels did you set in your Azure to read the time card data?

 

@Anonymous Can you please explain a bit more about how you moved the data retrieved from the graph into PowerBI?

On Power Automate (Flow) I can only see the add to existing data set action for PowerBI.

Did you move the retrieved data somewhere else first, like a CSV file, or did it go straight into PowerBI.

Thanks

Anonymous
Not applicable

Hello sjb9:

 In my application I ussed an OData feed to directly query the Graph (beta) API directly into PowerBi. The data is then updated when the report is refreshed. Have not yet worked with "Flow". The user is currently refreshing the reports as needed as a short term solution. Hope this helps.

 

= OData.Feed("https://graph.microsoft.com/beta/teams/your teams ID #/schedule", null, [Implementation="2.0"])

Hi @Anonymous ,

 

Thanks for sharing the solution!

 

 

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

$clientId = "XXXXXXXXXXXXXXXXXXXX"
$clientSecret = "XXXXXXXXXXXXXXXXXXXX"
$tenantName = "XXXXXXXXXXXXXXXXXXXX"
$resource = "https://graph.microsoft.com/"

$tokenBody = @{
Grant_Type = "client_credentials"
Scope = "https://graph.microsoft.com/.default"
Client_Id = $clientId
Client_Secret = $clientSecret
}
$tokenResponse = Invoke-RestMethod -Uri "https://login.microsoftonline.com/$TenantName/oauth2/v2.0/token" -Method POST -Body $tokenBody
#__________________________________#__________________________________#__________________________________#_______________________________

$URL = "https://graph.microsoft.com/beta/teams/XXXXXXXXXXXXXXXXXXXX/schedule"
$result = Invoke-RestMethod -Headers @{Authorization = "Bearer $($tokenResponse.access_token)"} -Uri $URL -Method Get -ContentType "application/json"

 

I use PowerShell

I have a mistake

 

Invoke-RestMethod : {
"error": {
"code": "Forbidden",
"message": "{\"error\":{\"code\":\"Forbidden\",\"message\":\"MS-APP-ACTS-AS header needs to be set for application context requests.\",\"details\":[],\"innererror\":{\"code\":\"MissingUserIdHeaderInAppContext\"}}}",
"innerError": {
"date": "2020-06-28T17:07:59",

 

How can I fix this error?

MS-APP-ACTS-AS

Anonymous
Not applicable

Did You manage to solve the problem?

just add parametr "user_id" in headers 

user_id who makes the requers (probably)

 

power query

 getDataApi = Json.Document(Web.Contents("https://graph.microsoft.com/v1.0/",
            [RelativePath = "teams/"&group_id &"/schedule/shifts", Headers = [Authorization = "Bearer "&token, #"MS-APP-ACTS-AS" = user_id], ManualStatusHandling={400}]))

 

 

Anonymous
Not applicable

The instruction specifies the {teamId} parameter, where can I get it?
Anonymous
Not applicable

MOOREJEFF_0-1593095055661.png

C

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.