I am attempting to create a interface between our web application and the GraphApi.
I am currently struggling to handle error correctly as the documentation for graph API seems to be at best incomplete. Is there a reference to full list of errors one should expect.
An example of the issue is where I make a request after my access token has expired. The error code is not on the list (graph.microsoft.io docs/overview/errors page) and in a different format (capitalization). It also seems to vary drastically from the azure error codes such as "Request_BadRequest". This was found in an MSDN article titled "Error codes and error handling | Graph API concepts".
The document states "You may use the information returned here instead of, or in addition to the HTTP status code returned.". However, this is really hard if they are changing despite being out of beta.
example of an error response body:
{ "error": {
"code": "InvalidAuthenticationToken",
"message": "Access token has expired.",
"innerError": {
"request-id": "267438d2-4cc5-4621-9307-2af26d2f5b49",
"date": "2016-02-16T13:30:24"
}
}
}
Related
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.
When making this GET request:
https://graph.microsoft.com/v1.0/me/events/{EVENT_ID}?%24select=id%2Csubject%2Ccategories%2CseriesMasterId",
The Graph API is returning HTTP 400 with the details below. I am unable to find documentation explaining this error. Any help would be greatly appreciated.
{
"code": "ErrorInvalidRequest",
"message": "Your request can't be completed. This operation does not support binding to a non-calendar folder.",
"innerError": {
"request-id": "8b92c8b2-3b52-4640-998f-cc07e56bdc27",
"date": "2019-04-26T21:17:18"
}
}
Update: This behavior seems to happen when querying for the status of an event that has been deleted by a user. Would be great for Microsoft to document this behavior -- assuming this is in fact intended.
There are three example URLs on this page https://developer.microsoft.com/en-us/graph/docs/concepts/onenote-get-content
Only the first one works.
graph.microsoft.com/v1.0/me/onenote/notes/pages got 400 BadRequest - Resource not found for the segment 'notes'.
graph.microsoft.com/v1.0/me/onenote/pages?select=title,self got 404 Not Found with error code 20102 and The specified resource ID does not exist.
https://github.com/microsoftgraph/msgraph-sdk-dotnet/blob/2c568d5b67f2d066a2a85fb4292e8d7efe317b97/docs/overview.md the example line of
await graphClient.Me.Onenote.Sections.Request().GetAsync() is also not working. Get 20102 too.
For Full Rest URL
graph.microsoft.com/v1.0/me/onenote/notebooks works.
graph.microsoft.com/v1.0/me/onenote/notebooks/{notebook_id} works.
graph.microsoft.com/v1.0/me/onenote/notebooks/{notebook_id}/sections works.
But graph.microsoft.com/v1.0/me/onenote/notebooks/{notebook_id}/sections/{section_id} does not work.
section_id is from the section list got from graph api. It will return with 404 Not Found with error below.
{
"error": {
"code": "UnknownError",
"message": "{\r\n \"Message\": \"No HTTP resource was found that matches the request URI
'https://www.onenote.com/api/V1.0/users({user_id})/notes/notebooks({notebook_id})/sections({section_id})'.\"\r\n}",
"innerError": {
"request-id": xxxxxx,
"date": xxxxxx
}
} }
Also not working with graph.microsoft.com/v1.0/me/onenote/notebooks/{notebook_id}/sections/{section_id}/pages
How can I read one page from my Onenote? I got NO DOCS or EXAMPLES can help me now.
Where is DOC for Graph SDK?
1.I think you may need to call the API interface likeļ¼
https://graph.microsoft.com/v1.0/users/{userid}/onenote/sections/{section-id}/pages or
https://graph.microsoft.com/v1.0/me/onenote/sections/{section-id}/pages
to read all pages from your Onenote.
2.You can call the Microsoft Graph API to get one page's content, and the request url like this:
https://graph.microsoft.com/v1.0/me/onenote/pages/{pageid}/content
3.You can get the content of the Graph API: https://developer.microsoft.com/zh-cn/graph/docs/concepts/v1-overview
4.Here are the Docs for Graph: https://developer.microsoft.com/en-us/graph/code-samples-and-sdks
5. I think you may need the graph explore to try some APIs. It has intellisense.
If you have further questions, please leave the comments below.
It seems there's an issue happening (at least within my tenant) when paging results from SharePoint Online lists; the URL provided in #odata.nextLink doesn't work, resulting in Error 500 (generalException).
I'm using a following query:
/beta/sites/[site URL],[site ID]/lists/[list ID]/items?expand=fields
The first page of results comes in correctly, and the #odata.nextLink property contains a following URL:
https://graph.microsoft.com/beta/sites/[site URL],[site ID]/lists/[list ID]/items?expand=fields&$skiptoken=Paged%3dTRUE%26p_ID%3d205
Unfortunately, using it results in:
{
"error": {
"code": "generalException",
"message": "An unspecified error has occurred.",
"innerError": {
"request-id": "f7e33c22-15b5-4aac-b928-31c1a2bf04ae",
"date": "2018-01-11T09:48:57"
}
}
}
This happens using both the /beta and /v1.0 endpoint.
Tested on multiple lists and sites within my tenant.
Tested without ?expand=fields
It was working perfectly before last Thursday (Jan. 11th).
The customer service for O365 is unable to help, pointing me to MSDN forums.
Thanks for bringing this to our attention Jakub. You found a regression that slipped through our testing - thankfully there was a quick solution so you should no longer reproduce the issue.
I am attempting to create an upload session in the special app folder for my OneDrive app using the Graph API. My app have the following permissions:
Files.ReadWrite
Files.ReadWrite.AppFolder
offline_access
The request looks like this
https://graph.microsoft.com/v1.0/users/xxxxxx96-2e02-4300-8ab0-a05d73xxxxxx/drive/special/approot:/documentname.docx:/createUploadSession
gives the following error:
{
"error": {
"code": "itemNotFound",
"message": "The resource could not be found.",
"innerError": {
"request-id": "7447aa01-6685-4af0-998a-64abc9b14825",
"date": "2017-04-06T10:07:46"
}
}
}
I can create an upload session on the normal root folder without any errors:
graph.microsoft.com/v1.0/users/xxxxxx96-2e02-4300-8ab0-a05d73xxxxxx/drive/root:/documentname.docx:/createUploadSession
result:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#microsoft.graph.uploadSession",
"expirationDateTime": "2017-04-06T10:32:48.5252565Z",
"nextExpectedRanges": [
"0-"
],
"uploadUrl": "......."
}
The createuploadsession method does not support special/approot. As mentioned in the documentation, these are the only paths to use:
POST /drive/root:/{path_to_item}:/createUploadSession
POST /drive/items/{parent_item_id}:/{filename}:/createUploadSession
Just wanted to clarify, since people are sometimes referring to this thread still: This syntax actually is supported. Due to the flexibility of OData syntax/support, the docs are not always 100% comprehensive about every request path that works.
I believe the actual issue is that Files.ReadWrite.AppFolder is not supported on ODB/SPO/business accounts yet (as of 2022) - it is only for personal/MSA accounts. However, there is work in progress to bring this support to SPO in the future.
The two scopes that are mentioned above are:
Files.ReadWrite - grants access to content on the caller's mysite only
Files.ReadWrite.AppFolder - has no effect on SPO/business
Files.ReadWrite.All should work in the short term, until Files.ReadWrite.AppFolder is implemented on SPO/ODB.