microsoft-graph api users endpoint with filter provides NextLink Token Expired - microsoft-graph-api

Removing my code as part of the equation, I was able to reproduce this through the Microsoft Graph API Explorer.
First, I Do a GET https://graph.microsoft.com/v1.0/users?$filter=assignedLicenses%2fany(d%3ad%2fskuid+eq+ --actualySKUIDHere--)
I get results back like
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#users",
"#odata.nextLink": "https://graph.microsoft.com/v1.0/users?$filter=assignedLicenses%2fany(d%3ad%2fskuid+eq+
--actualSKUIDHere-- )&$skiptoken=X%27 --actualtokenhere-- %27",
"value": [
{
I copy paste the nextLink into the API Explorer
ie.
https://graph.microsoft.com/v1.0/users?$filter=assignedLicenses%2fany(d%3ad%2fskuid+eq+ --actualSKUIDHere-- )&$skiptoken=X%27 --actualtokenhere-- %27
and it works with good results like above, but the next skipToken is shorter and copy & pasting it will result in the following
{
"error": {
"code": "Directory_ExpiredPageToken",
"message": "The specified page token value has expired and can no longer be included in your request.",
"innerError": {
"request-id": "4cce84ea-83c5-403a-98d2-5ad5c948fcdc",
"date": "2020-02-03T21:04:43"
}
} }
I'm assuming this is a bug but wanted to post to see if anyone else has experienced this and has a resolution

This was a temporary service issue which has been fixed since. You should not try to parse/modify the next link in your application, simply use it as provided by the service.

Related

Teams Export API not allowing me to filter by channel

I'm trying to use the Teams Export API to export a single Teams channel. I have my permissions set up properly; if I make a request to
https://graph.microsoft.com/v1.0/teams/{TEAM_ID}/channels/getAllMessages (without specifying a filter), I get the paginated results of all of the channel messages on my team. If I copy the sample datetime filters in that documentation, I also get a successful response with the appropriate results.
A successful response gives me a list of messages. Each one shows a channelIdentity field, which contains a channelId (fields removed for readability):
{
"value": [
{
"channelIdentity": {
"teamId": "{TEAM ID}",
"channelId": "{CHANNEL ID}"
},
},
]
}
What I want is to use this channelIdentity/channelId field as a filter on the results, so that I can export just the messages from a single channel.
If I run GET https://graph.microsoft.com/v1.0/teams/{TEAM_ID}/channels/getAllMessages?$filter=channelIdentity/channelId eq '{CHANNEL ID}', I get an error:
{
"error": {
"code": "BadRequest",
"message": "The entity property 'channelIdentity/channelId' and operationKind 'Equal' is not allowed in $filter query.",
"innerError": {
"date": "2022-11-16T23:47:06",
"request-id": "...",
"client-request-id": "..."
}
}
}
This reads to me like I'm not allowed to use eq with this ID. If I try a 'starts with', I get a different error:
GET https://graph.microsoft.com/v1.0/teams/{TEAM_ID}/channels/getAllMessages?$filter=startswith(channelIdentity/teamId, '{CHANNEL ID}')
{
"error": {
"code": "BadRequest",
"message": "Only binary operation expressions are allowed.",
"innerError": {
"date": "2022-11-17T00:11:26",
"request-id": "...",
"client-request-id": "..."
}
}
}
I'm unclear on what this is trying to say - either the ID starts with that phrase or it doesn't; it seems like a binary expression to me.
Is there some other approach I should use to get these results filtered by channel ID?
This API is designed to export everything from a team for backup/archival scenario. So, filtering by a specific channel is not supported now.
If you wish you may suggest this feature on Microsoft Feedback portal.
Any reason why you don't use List Channel Messages?
You can then make a GET call against this URL:
"https://graph.microsoft.com/v1.0/teams/{teamid}/channels/{channel id}/messages"
Note - as per that link you will need to Request access:
https://learn.microsoft.com/en-us/graph/teams-protected-apis
One other method, if you are using Graph Explorer, is add the signed-in user to the team as an owner, and it will let you test this method, you just won't be able to call via an App Registration until you do fill out that form.

Create Team, 400 Bad Request, Required functionality is not supported

I'm trying to create a Microsoft Teams team in Migration mode via the Graph API. However I get a 400 response that I can't figure out. The query is shared in the link below.
Shared Query
For those that don't want to view it that way, here is my request:
POST https://graph.microsoft.com/beta/teams
Authorization: Bearer ...
Content-Type: application/json
{
"#microsoft.graph.teamCreationMode": "migration",
"template#odata.bind": "https://graph.microsoft.com/beta/teamsTemplates(\u0027standard\u0027)",
"displayName": "SlackMigrationTest",
"description": "testing slack migrations",
"createdDateTime": "2021-01-14T00:00:00.000Z"
}
I created this based on the microsoft doc here.
The reponse I get is:
The remote server returned an error: (400) Bad Request.
{
"error": {
"code": "BadRequest",
"message": "Required functionality is not supported.",
"innerError": {
"date": "2021-01-20T15:51:21",
"request-id": "dc4189cf-db4a-4a60-a271-f63b5d759a05",
"client-request-id": "dc4189cf-db4a-4a60-a271-f63b5d759a05"
}
}
}
I'm sure its something obvious that I'm missing but any help would be greatly appreciated.
Here you are using the User Context token and trying to make the call. This API call only works in Application context as shown in the below screenshot.
So use Client Credential flow and set Application permissions and then make a call.
As you can see below, it worked for me with App token.
You cannot test it in graph explorer because the Graph Explorer gets user token.

List events API call on Microsoft Graph Java SDK doesn't work for #outlook.com domain

When I tried the following GET request using Microsoft Graph explorer:
https://graph.microsoft.com/beta//me/calendars/joseph.baker.doodle#outlook.com/calendarView?startDateTime=2019-10-24T07:40:43.133Z
I got this response:
{
"error": {
"code": "ErrorInvalidIdMalformed",
"message": "Id is malformed.",
"innerError": {
"request-id": "7ffa9b3c-b5bf-4171-b5ad-242dd831b629",
"date": "2019-11-21T06:30:12"
}
}
}
When I try it with user's calendar ID:
https://graph.microsoft.com/beta//me/calendars/AQMkADAwATM3ZmYAZS0yNDI1LTEwMmMtMDACLTAwCgBGAAADWt9re56XX0ay-rq-yg7yKwcA94f8IFhbyEuRrCHknQvqSwAAAgEGAAAA94f8IFhbyEuRrCHknQvqSwAAADW523EAAAA=/calendarView?startDateTime=2019-10-24T07:40:43.133Z&endDateTime=2019-10-31T07:40:43.133Z
Also for an account with #onmicrosoft.com:
https://graph.microsoft.com/beta//me/calendars/joseph.baker.doodle#onmicrosoft.com/calendarView?startDateTime=2019-10-24T07:40:43.133Z
It works as expected.
Can somebody help me with this? Is the issue domain-related?
Calendars are always referenced by id instead of name. Also, since Outlook.com is a single-user platform, it simply isn't possible to reference another user's resources.
I'm frankly surprised /me/calendars/joseph.baker.doodle#onmicrosoft.com/ since this is not a supported/documented address scheme.

Microsoft Graph SharePoint access items (read/write)

I am attempting to create a new list item in SharePoint Online using the [beta] Microsoft Graph endpoint. The goal is to call Microsoft Graph from an Outlook Add-in but the problem persists on Postman.
When I call the endpoint as per the documentation I get the following error message:
{
"error": {
"code": "unauthenticated",
"message": "The caller is not authenticated.",
"innerError": {
"request-id": "bb094f39-71c9-4c7d-9d9b-913cc9622baf",
"date": "2017-08-08T11:32:02"
}
}
}
I'm using ADAL JS to fetch the authentication token and I initialized my AuthenticationContext with my tenantID. My app has the following permissions: offline_access, Sites.Read.All, Sites.ReadWrite.All, User.Read
2nd Edit - more details on readItem
I use the https://graph.microsoft.com/beta/sites/{site-id}/lists/{list-id}/items endpoint with the {site-id} of my desired site from /sites and the {list-id} of the list from /sites/{site-id}/lists but this is the empty response I get:
{
"#odata.context": "https://graph.microsoft.com/...",
"value": []
}
If I try to to add /{item-id} to my original call to access specific item I receive this response:
{
"error": {
"code": "itemNotFound",
"message": "The specified list was not found",
"innerError": {
"request-id": "6e7ccae3-3aee-4dbb-ae3e-de61250478e0",
"date": "2017-08-09T13:13:33"
}
}
}
Which doesn't make sense because I can retrieve valid information about the list if i make the call without /items/..
Any and all input appreciated :) I'll gladly provide more code, this is all I deemed relevant and didn't want to overcrowd the post.
might be that you actually don't have an item with that id, since https://graph.microsoft.com/beta/sites/{site-id}/lists/{list-id}/items/1 works for me.
test the id's you really have by just https://graph.microsoft.com/beta/sites/{site-id}/lists/{list-id}/items and each item returns it's id.

Unable to access the Sharepoint List using Microsoft Graph API--

Working with the Microsoft graph api and especially the sharepoint beta api and i am constantly running into issues. I know its beta, but still;)
SO the issue is When i tried to access the sharepoint list using Graph API in graph explorer
URL is: GET https://graph.microsoft.com/beta/sites/{site-id}/lists/{list-id}
So SiteID i am passing my site tenant GUID and List ID as Sharepoint List GUID
and i am facing the error continously in Response
{
"error": {
"code": "invalidRequest",
"message": "Provided id is not suitable for the current host",
"innerError": {
"request-id": "61efc5b1-88f8-442c-a41d-7213b587318e",
"date": "2017-05-10T07:38:04"
}
}
}
IF any one also has faced this issue please let me know the solution you have resolved
The format of the ID's for sites have changed as part of a set of updates to the API this week. The new format is documented here, but it includes the SharePoint hostname, SPSite.ID, and SPWeb.ID as a triplet:
https://graph.microsoft.com/beta/sites/contoso.sharepoint.com,fc016e3c-d8ae-4ee0-a10c-de6d26788b6a,9a4ea7a5-c3c4-44ae-9f80-273bd67431b8
If you add the hostname into your IDs, your calls should start working again. You can discover the hostname by making a request to:
https://graph.microsoft.com/beta/sites/root/siteCollection/hostname
You can also search for sites now using the following search syntax:
https://graph.microsoft.com/beta/sites?search={keyword}
#Ryan Gregg has the correct answer
The SiteId is not just one GUID but a combination of <HostName,SPSite.ID,SPWeb.ID>.
Example: <contoso.sharepoint.com,fc016e3c-d8ae-4ee0-a10c-de6d26788b6a,9a4ea7a5-c3c4-44ae-9f80-273bd67431b8>
The whole string in the above example is what you should pass for {SiteId} in your request
If you dont have the SPSite.ID but have the URL for the site, you can make a GRAPH API call with relative path to the site
https://graph.microsoft.com/v1.0/sites/contoso.sharepoint.com:/sites/Documetation
This call will return all the properties for the site and you can grab the full SiteId from here:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#sites/$entity",
"createdDateTime": "2020-04-23T12:18:48.653Z",
"description": "Documentation",
"id": "contoso.sharepoint.com,fc016e3c-d8ae-4ee0-a10c-de6d26788b6a,9a4ea7a5-c3c4-44ae-9f80-273bd67431b8",
"lastModifiedDateTime": "2020-12-09T19:17:21Z",
"name": "Documentation",
"webUrl": "https://contoso.sharepoint.com/sites/Documentation",
"displayName": "Documentation",
"root": {},
"siteCollection": {
"hostname": "contoso.sharepoint.com"
}
}
Try https://graph.microsoft.com/beta/sites/{siteCollectionId},{siteId}/lists
You can find these ids from https://graph.microsoft.com/beta/site/sites

Resources