Forum Discussion
Get data from Microsoft teams (shifts)
- Anonymous6 years ago
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 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.
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
- Anonymous6 years agoNot applicableThe instruction specifies the {teamId} parameter, where can I get it?
- Anonymous6 years agoNot applicable
C
- Anonymous6 years agoNot 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.
- Anonymous6 years agoNot 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
- Anonymous6 years agoNot 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}]))
- sjb96 years agoNew Member
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
- Anonymous6 years agoNot 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"])
- pmahawar2 years agoNew Member
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?