Microsoft Graph API for Education: error listing user schools - microsoft-graph-api

I'm trying to retrieve the educationShool list of an educationUser from Microsoft Graph per the API reference:
I am getting this error:
Error message: The request URI is not valid. Since the segment
'memberOf' refers to a collection, this must be the last segment in
the request URI or it must be followed by an function or action that
can be bound to it otherwise all intermediate segments must refer to a
single resource.
I have reproduced this issue in the Graph Explorer, if I try to send this request, I get the same error:
https://graph.microsoft.com/v1.0/education/me/schools
If I try to list the Classes (I think it should be a very similar scenario), it works ok:
https://graph.microsoft.com/v1.0/education/me/classes
Am I doing something wrong, or is this a bug in the API?

I was able to reproduce this and it looks like there may be a bug here. While that gets investigated, I can confirm that it works properly in the /beta release:
https://graph.microsoft.com/v1.0/education/me/schools
I'd suggest using /beta for this particular call if possible.
Update: This issue has been resolved and education/{users}/schools should now be working in both v1.0 and Beta versions.

Related

Microsoft Graph API - get drive "Url specified is invalid."

I am facing a weird issue with microsoft's graph api.
I am trying to retrieve files stored on Sharepoint. I don't know what the issue is and I have tried a lot of different things:
Call to get all drives for the site works and returns a list of all available drives:
GET https://graph.microsoft.com/v1.0/sites/site.sharepoint.com,<id>,<id>:/teams/myTeam:/drives
Via the previous endpoint I can extract the id for that drive with which I would then like to retrieve drive details (and in consequence all children of that drive):
GET https://graph.microsoft.com/v1.0/sites/site.sharepoint.com,<id>,<id>:/teams/myTeam:/drives/<driveId>
GET https://graph.microsoft.com/v1.0/sites/site.sharepoint.com,<id>,<id>:/teams/myTeam:/drives/<driveId>/root
GET https://graph.microsoft.com/v1.0/sites/site.sharepoint.com,<id>,<id>:/teams/myTeam:/drives/<driveId>/root/children
But all 3 above endpoints throw a 400 Bad Request Error with message: Url specified is invalid.
Additional information:
My access token has the following scopes: Sites.FullControl.All User.Read profile openid email
I am able to retrieve an individual drive item through the list endpoints (but the folder structure is quite complex and I need to list several layers of folders/files - this is why I believe the syntax with drive would be a lot more convenient):
GET https://graph.microsoft.com/v1.0/sites/site.sharepoint.com,<id>,<id>:/teams/myTeam:/lists/<list-id>/items/<item-id>/driveItem
via the field parentReference I am also able to fetch the driveId and even the relative path (/drives/<drive-id>/root:) but I also have no idea how I would get the content from that.
Help is greatly appreciated as I have been stuck for a long time now - thank you!
Try with the below HTTP call.
https://graph.microsoft.com/v1.0/sites/site.sharepoint.com,<id>,<id>/drives/driveid/root/children
It worked for me.

Add reaction to existing posts or comments

How can we "like" or add other reactions to someone else's channel message or comment via the Graph API?
I've not done this myself, but it certainly looks possible. You need to reply to the message, as per https://learn.microsoft.com/en-us/graph/api/channel-post-messagereply?view=graph-rest-1.0&tabs=http and notice that it has a "reactions" collection. That would be populated with a chatMessageReaction type, as per https://learn.microsoft.com/en-us/graph/api/resources/chatmessagereaction?view=graph-rest-beta
Note of warning: chatMessageReaction is a beta type though, so just be aware you need to call the beta endpoint, and it has a risk to use in production code as things might change.
Update: We reached out to MS Support and received the following info: "The API to reply to a message using a POST /replies request is solemnly for issuing a reply to a message, and not to edit the status of the parent message itself. Moreover, the "update chatMessage" API which is a PATCH /messages and which is the only API to edit a parent message only supports updating the policyViolation property of a chatMessage. Essentially, there is currently no documented API / already-present API examples on how to add a reaction, making this purely unsupported."

Graph Schedule + Shifts API: MS-APP-ACTS-AS header needs to be set for application context requests

I am having issues running a GET against both the schedules and shifts v1.0 API. The documentation on the MS KB doesn't indicate that this is in preview any more, so I'm unsure what we're doing wrong here. The API is running with an app-only auth token
Postman screenshot
Currently we are doing prelim testing via postman to ensure we can use the API correctly.
The app in question has been given the following permissions:
Schedule.Read.All
Schedule.ReadWrite.All
We can view the teamId information correctly at https://graph.microsoft.com/v1.0/teams/{{TeamId}}, but schedules or schedules/shifts returns the error
Based on a previous answer I saw, I added the MS-APP-ACT-AS header with a UserId to act as, but it returned the same error
Thanks
Try to use this header instead:
MS-APP-ACTS-AS
In your question you wrote:
MS-APP-ACT-AS
(Missing the 'S')

Count of user/members from group azure AD using graph API

I need to take a count of each group from Azure AD using Graph API. Can anyone tell me how to achieve it
I also faced the similar issue. When I ran the end point mentioned in https://learn.microsoft.com/en-us/graph/api/group-list-members?view=graph-rest-1.0&tabs=http#example-2-get-only-a-count-of-all-membership I got "$count is not currently supported."
However, if you notice the documentation clearly, it asks us to send in the ConsistencyLevel as eventual in the REST header. I got the correct response when I sent the header along with the call:
GET https://graph.microsoft.com/v1.0/groups/{id}/members/$count ConsistencyLevel: eventual
There is currently no Microsoft Graph endpoint to get the number of users.
You could list members by using:
GET https://graph.microsoft.com/v1.0/groups/{id}/members
And then handle the count of the members in your code.
See the reference here. Try it quickly with Microsoft Graph Explorer.

Returning employeeId of a user through MS Graph API

I've been trying to return the employeeId of a user through the Microsoft Graph API but so far haven't had much luck.
I'm assuming this is probably because it doesn't exist in the metadata for the user in the Graph API so makes sense.
However, the property is populated in Azure AD. If I use the AZ command prompt to query the user I can see the property. Likewise, if I query the old Active Directory Graph API endpoint I can even see it there.
For example, querying
https://graph.windows.net/{tennant}/users/{upn}?api-version=1.6 directly I receive the employeeId as part of the response (using the ActiveDirectoryClient however seems to ignore this property and doesn't store it anywhere).
Is there any reason for this? Wouldn't it make sense to have it returned as an additional property? I've also looked into extensions, but as it's not an extension isn't returned there.
Any help would be appreciated. I can get the information I need by querying the old endpoint directly, but this seems like a complete backwards step and involves multiple queries to get the information I need - including having to use multiple end points (one of which I assume will be deprecated and removed soon).
EmployeeId is currently a beta feature and is only available in the beta endpoint of the Graph API.
So if you want to access the beta endpoint you just have to change the version to beta in your url. For example:
https://graph.microsoft.com/beta/me/
https://graph.microsoft.com/beta/users/{id|upn}/
https://graph.windows.net/{tennant}/users/{id|upn}?api-version=beta
For more information about the user-object in the beta endpoint see: https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/resources/user

Resources