400 when accessing shared file using graph api with shared url - microsoft-graph-api

I called the endpoint /shares/{shareId} using msgraph-sdk-php, but got response 400 as:
{
"#odata.context":"https://graph.microsoft.com/v1.0/$metadata#shares/$entity",
"id":"s!here-is-the-share-id",
"name#odata.type":"#String",
"name":{
"error": {
"code": "BadRequest",
"message": "A primitive value was specified; however, a value of the non-primitive type '' was expected.",
"innerError": {
"request-id": "3ea56b1c-acd6-4fdf-a856-c46b35e01cb7",
"date": "2017-05-25T05:26:23"
}
}
}
(Yes, I even got 4 left brackets but only 3 right brackets.)
while I can get correct response via api.onedrive.com api with the same shareId.
I really can't find any tips from documentation.

Thanks for letting us know about this #SevenOutman! This was a configuration issue that has now been resolved.

Related

Microsoft Graph API CallRecord with expanded sessions returns an error

When I execute a request for a specific callRecord like this it works:
https://graph.microsoft.com/v1.0/communications/callRecords/{id}
But when I do this I get an error (500):
https://graph.microsoft.com/v1.0/communications/callRecords/{id}?$expand=sessions
{
"error": {
"code": "InternalServerError",
"message": "Object reference not set to an instance of an object.",
"innerError": {
"date": "2022-04-14T12:21:34",
"request-id": "{guid}",
"client-request-id": "{guid}"
}
}
}
It looks like this doesn't happen for every callRecord though. We started seeing this error in our logging around 2022-04-11T00:24:00Z, now we get thousands of those.
It was an internal issue on Microsoft's side. Everything seems to be fixed.

500 error "nextLink value without skip or skiptoken" delta API

I'm trying to track changes on a sharepoint drive but I got an obscure error message.
Here my call:
https://graph.microsoft.com/v1.0/drives/{direvId}/root/delta
And here the response:
{
"error": {
"code": "InternalServerError",
"message": "nextLink value without skip or skiptoken",
"innerError": {
"date": "2021-02-03T16:38:03",
"request-id": "4cb9de13-817d-47c7-a0b3-2605470789b9",
"client-request-id": "4cb9de13-817d-47c7-a0b3-2605470789b9"
}
}
}
Any clue?
EDIT:
The issue is releated to the application access token.
Ok I found the issue. Using postman and having the header Prefer set as follow Prefer: apiversion=2.1 was causing the 500 error.
With no Prefer header set or using the headers suggested in the documentation everything is working as expected.enter link description here

How to access shifts of a team? "Sorry, the team was not found, or you may not have access to it"

I would like to read a team's shifts using https://graph.microsoft.com/v1.0.
However i always fail with different errors and get contradicting server messages.
I send the API requests with Postman.
I am using Application authorization method. I think i have set all required Api permissions for my app.
I beleive i supply the correct headers, like:
Authorization
Content-Type
MS-APP-ACTS-AS
When i send the request like this to GET a team:
GET https://graph.microsoft.com/v1.0/teams/{id}
i get the following error message:
"error": {
"code": "NotFound",
"message": "No team found with Group Id {id}",
"innerError": {
"date": "2020-09-05T08:37:17",
"request-id": "id"
}
}
But when i try to create the team (from a group) like this:
PUT https://graph.microsoft.com/v1.0/groups/{id}/team
I get the error as follows:
"error": {
"code": "Conflict",
"message": "Team already exists",
"innerError": {
"date": "2020-09-05T08:33:33",
"request-id": "id"
}
}
When i try to make my actual call of interest, like:
GET https://graph.microsoft.com/v1.0/teams/{id}/schedule/shifts
That also fails with error:
{
"error": {
"code": "NotFound",
"message": "{\"error\":{\"code\":\"NotFound\",\"message\":\"Sorry, the team was not found, or you may not have access to it.\",\"details\":[],\"innererror\":{\"code\":\"TeamNotFound\"}}}",
"innerError": {
"date": "2020-09-05T08:59:55",
"request-id": "id"
}
}
}
Pleaset help me understand what i am doing wrong!
Thank you in advance!
Solved (itself).
So what was happening:
i created a team (directly or from a group).
created a schedule for the team.
get the schedule for the team, and see the response:
"enabled": false,
"provisionStatus": "Failed", (so not running or queuing or something)
"provisionStatusCode": "GraphResourceNotFound",
struggle few (like 4-5) days
without changing a thing, get the schedule showing:
"enabled": true,
"provisionStatus": "Completed",
"provisionStatusCode": null,
Maybe it would help others to see the possible wait time length or add a clarification about the provisionStatus field’s status progression.

Receiving 400s and 500s when attempting to get singleValueExtendedProperties

trying to add extended properties to calendar objects. I am able to create calendars with the following payload (Ruby syntax, payload is sent as a JSON):
name: build_calendar_name,
singleValueExtendedProperties: [{
id: "String {#{SecureRandom.uuid}} Name setting_id",
value: #setting_id.to_s
}]
I receive a 201 from this request and the calendar is created no problem
The frustrating part is I cannot retrieve the extended property when making a GET request. The following two requests should work:
GET /me/events/calendar_id?$expand=singleValueExtendedProperties($filter=id eq 'String {guuid} Name setting_id')
Response
{
"error": {
"code": "BadRequest",
"message": "Parsing OData Select and Expand failed: Found an unbalanced bracket expression.",
"innerError": {
"date": "2020-07-01T22:38:14",
"request-id": "<hidden>"
}
}
}
GET /me/calendars?$filter=singleValueExtendedProperties/Any(ep: ep/id eq 'String {guuid} Name setting_id' and ep/value eq 'setting_id')
Response:
{
"error": {
"code": "ErrorInternalServerError",
"message": "An internal server error occurred. The operation failed.",
"innerError": {
"date": "2020-07-01T22:40:15",
"request-id": "<hidden>"
}
}
}
Guuid, calendar_id and setting_id are dummy values, real values are used when attempting these calls.
We've also tried following the examples verbatim at this link https://learn.microsoft.com/en-us/graph/api/singlevaluelegacyextendedproperty-get?view=graph-rest-1.0&tabs=http#example and still receive these response codes. Would love some help with this. Thanks!
I reproduced this for the $expand case in Graph Explorer. The problem seems to be the = inside the parentheses. If you URL-encode that to %3D the query works fine.
$expand=singleValueExtendedProperties($filter%3Did eq 'String {guuid} Name setting_id')
For the $filter, I reproduce it when doing GET /me/calendars, but not when doing GET /me/events. This seems to be a problem with the service (unless the docs are just wrong). Let me check and report back.

Unable to delete AppRoleAssignment using Beta Graph API

I'm using the Graph API beta endpoint to try and delete an AppRoleAssigmnet:
https://graph.microsoft.com/beta/appRoleAssignments/I9pzftcx_06aCwX8sV9cmziqx-oiF21IlkxV9xRYvBM
I am using the DELETE verb and below is the response I get back:
109
{
"error": {
"code": "Request_UnsupportedQuery",
"message": "Direct queries to this resource type are not supported.",
"innerError": {
"request-id": "aa7c14a3-f700-4368-898e-009f1608ade1",
"date": "2019-04-30T00:29:50"
}
}
}
0
According to the beta documentation, this is allowed:
https://learn.microsoft.com/en-us/graph/api/approleassignment-delete?view=graph-rest-beta
I also verified the correct permissions according to the documentation as well.
I know this is a beta endpoint but any chance this will be fixed soon or do I need to use the Azure AD API instead?
UPDATE
I tried going through the users collection and it also fails:
https://graph.microsoft.com/beta/users/7e73da23-31d7-4eff-9a0b-05fcb15f5c9b/appRoleAssignments/I9pzftcx_06aCwX8sV9cmziqx-oiF21IlkxV9xRYvBM
I am using the DELETE verb and below is the response I get back:
fb
{
"error": {
"code": "BadRequest",
"message": "Write requests are only supported on contained entities",
"innerError": {
"request-id": "b6db0eee-dc45-4e10-a56c-9a870fb7315c",
"date": "2019-04-30T23:49:24"
}
}
}
0
I tried going through the service principal collection and it also fails:
https://graph.microsoft.com/beta/servicePrincipals/27e0a182-2008-4b4e-b998-731e0d111041/appRoleAssignments/I9pzftcx_06aCwX8sV9cmziqx-oiF21IlkxV9xRYvBM
I am using the DELETE verb and below is the response I get back:
18b
{
"error": {
"code": "BadRequest",
"message": "The type 'microsoft.graph.appRoleAssignment' does not inherit from and is not a base type of 'microsoft.graph.directoryObject'. The type of 'KeySegments' must be related to the Type of the EntitySet.",
"innerError": {
"request-id": "8c981e82-755e-4c25-b448-58d2b71e12c7",
"date": "2019-04-30T23:46:20"
}
}
}
0
I'm afraid this service bug has existed for a very long time. The only thing I can say is to try this with AAD Graph until this is fixed in Microsoft Graph. The schema unfortunately models appRoleAssignments as a standard relationship, whereas in fact it is implemented as a contained entity (i.e. you can only operate on the app role assignment when it is contained as part of another entity - like users, groups or servicePrincipals). The schema definition needs to be updated. The documentation is accurate IMHO.
Hope this helps

Resources