Getting error "invalidRequest" when creating upload session (Microsoft Graph Api) - microsoft-graph-api

I am getting the below error when creating upload session (Microsoft Graph Api).
{
"error": {
"code": "invalidRequest",
"message": "Invalid request",
"innerError": {
"request-id": "6e9cc58e-d3b9-456e-a794-90486969296e",
"date": "2020-04-06T20:53:18"
}
}
}
Post request https://graph.microsoft.com/v1.0/me/drive/root:/testapi:/createUploadSession
Request body :

I have modified the request as below to make it work. See below :
POST https://graph.microsoft.com/v1.0/me/drive/items/01WCLVX5B7JBMYFMQKWNA3NVFODWCDUPGB:/3.pdf:/createUploadSession

I was implementing C# from here where the code was
var uploadSession = await graphClient.Me.Drive.Root
.ItemWithPath(itemPath)
.CreateUploadSession(uploadProps)
.Request()
.PostAsync();
In my case, I was able to fix it by updating itemPath by adding the full path to the file. For instance, if the path is
/RootFolder/Folder1
just update with file name like this
/RootFolder/Folder1/MyFile.pdf

Related

Issue while accessing data from Graph API

When accessing data using https://graph.microsoft.com/beta/teams/{id}, it is failing with 400 bad request without any error details. {id} is the value received from the response of https://graph.microsoft.com/beta/groups.
Following response is returned.
{
"error": {
"code": "AuthenticationError",
"message": "Error authenticating with resource",
"innerError": {
"date": "2021-10-15T15:01:43",
"request-id": "1d82fe40-5186-46fc-9fb7-c16341eb1ffb",
"client-request-id": "29c9e68d-bfd8-6f53-65c4-c49a82581a76"
}
}
}
We tried using MS graph SDK as well as graph explorer. All the consent are given for the end point.
What could be the reason for the error?

pathIsTooLong is not returned from createUploadSession api

When we try to upload file to specified folder over maximum path length, the following error occurs from createUploadSession api.
{
"error": {
"code": "invalidRequest",
"message": "One of the provided arguments is not acceptable.",
"innerError": {
"request-id": "...",
"date": "..."
}
}
}
We expect to include "pathIsTooLong" code in error response body then.
https://developer.microsoft.com/en-us/graph/docs/concepts/errors#error-resource-type
Is this correct behavior?
About CreateUploadSession API
https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/driveitem_createuploadsession
According to your descriptions, you want to include "PathIsTooLong" in error response body.
We can post a suggestion here Url: https://todo.uservoice.com/.

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.

Internal Server Error when Deleting Event from Group Calendar

I am primarily using the .net Microsoft graph client. I can create and change a group calendar's events with the API, but cannot delete them.
I know that my GraphServiceClient has a good user context token.
My code is
await client.Groups[GroupId.ToString()].Events[DeadlineId].Request().DeleteAsync();
I have also tried using an HTTP client "Delete" event to https://graph.microsoft.com/v1.0/groups/{GroupId}/events/{EventId}
The response I get is:
Error Received:
{
"error": {
"code": "ErrorInternalServerError",
"message": "[0x30140102] BodyTag",
"innerError": {
"request-id": "2ab3ad41-b6e2-47d1-88cc-ef3a3640d153",
"date": "2017-06-29T04:08:38"
}
}
}
Am I doing something wrong or is there a problem on Microsoft's end?

Microsoft Graph API Application Logo

With the May 2017 beta update, retrieve the application logo through the GRAPH API changed from mainLogo to Logo. When tested through the Graph Explorer with the new API, it's now given an error message as follows, tried the logoUrl property, it also failed.
API Call
https://graph.microsoft.com/beta/applications/[ApplicationID]/logo
{
"error": {
"code": "Request_UnsupportedQuery",
"message": "This property logo cannot be read. Please use the logoUrl property.",
"innerError": {
"request-id": "623806c0-6255-4b7d-bce1-d1cb7a982e6c",
"date": "2017-06-09T20:21:37"
}
}
}
logoUrl is under info, for example https://graph.microsoft.com/beta/applications/[ApplicationID]/info/logoUrl

Resources