Microsoft Graph API set owner role for file - microsoft-graph-api

Using Microsoft Graph is it possible to assign a the "owner" role to a SharePoint drive item? I can achieve this using the UI but do not seem to be able to do this using Graph.
I have tried the following method:
PATCH https://graph.microsoft.com/v1.0/groups/{groudId}/sites/root/drives/{driveId}/items/{itemId}/permissions/{permId}
Body:
{
"roles": [
"owner"
]
}
Return:
{
"error": {
"code": "invalidRequest",
"message": "Invalid value for role",
"innerError": {
"date": "2023-01-07T07:57:17",
"request-id": "b849af34-5b2d-4f50-94bd-b6ac15947eb8",
"client-request-id": "224905e8-ffb3-2dd1-6223-60ec9e5ad2a9"
}
}
}
However what confuses me is if I assign the same permission group full control to the drive item in the UI the same permission object will return "owner" as the role.

I was facing the similar issue long time ago and fixed it by using sp.full control instead of owner. Maybe it will work for you.
PATCH /v1.0/groups/{groudId}/sites/root/drives/{driveId}/items/{itemId}/permissions/{permId}
Body:
{
"roles": [
"sp.full control"
]
}

Related

Deprecate term from term store using Microsoft Graph API

I am trying to deprecate a Term from my term store using Microsoft Graph API.
I tried to update the term properties to achieve this using the UPDATE action as below but this is not working.
PATCH sites/{site-id}/termStore/sets/{set-id}/terms/{term-id}
{
"properties": [
{
"deprecated": true
}
]
}
I get the following response:
{
"error": {
"code": "generalException",
"message": "Object reference not set to an instance of an object.",
"innerError": {
"date": "XX",
"request-id": "XX",
"client-request-id": "XX"
}
}
}
I do have the TermStore.ReadWrite.All permissions.
Is this even possible to do?
If yes, do you know how to do this?
Mostly this could be happening because your user doesn't have sufficient privileges for the group under which you are trying to update the term. Your user needs to be at least a 'contributor' to the parent group of this term.

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.

Cannot get a person by its id using ms-graph people API

I'm using the Microsoft Graph People API and when I look at the docs here you can get a person by using its id:
I use the Graph Explorer to get people with the following API call:
https://graph.microsoft.com/v1.0/me/people?$select=id
I successfully get a list of ids.
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#users...",
"#odata.nextLink": "https://graph.microsoft.com/v1.0/me/people?$select=id&$skip=10",
"value": [
{
"id": "ddb9e9e4-a4cc-46ee-93f4-ba135920c84a"
},
{
"id": "37136f8b-33b3-4596-a63b-d41dc8edda34"
},
{
"id": "8c13d891-bd2f-42e5-8650-450b3318f8e3"
}
]
}
Then I use one of the ids to get more info about a single person by using this call:
https://graph.microsoft.com/v1.0/me/people/ddb9e9e4-a4cc-46ee-93f4-ba135920c84a
And I get an error:
{
"error": {
"code": "ErrorInternalServerError",
"message": "An internal server error occurred. The operation failed.",
"innerError": {
"request-id": "6e138441-5e1d-4f04-a87b-8141547cbb07",
"date": "2018-05-04T06:36:22"
}
}
}
Am I doing sth wrong ?
I'm also getting this error when following Microsoft's documenation.
As a workaround I added a filter.
https://graph.microsoft.com/v1.0/me/people?$filter=id eq 'ddb9e9e4-a4cc-46ee-93f4-ba135920c84a'
Unfortunately is seems that filtering by id is not supported at this time.
If you have the persons name you can use a filter like this:
https://graph.microsoft.com/v1.0/me/people?$filter=givenName eq 'Baris'
At the end of the day I prefer to use /users endpoint to get this type of information.
https://graph.microsoft.com/v1.0/users?$filter=id eq 'ddb9e9e4-a4cc-46ee-93f4-ba135920c84a'
or
https://graph.microsoft.com/v1.0/users?$filter=startswith(givenName, 'Baris')
Hope this helps!

Issues creating schema extensions using Graph Explorer

I have logged into my dev tenant as the tenant admin and I'm trying to create a schema extension, but I get a 403 Authorization_RequestDenied.
I have granted Directory.AccessAsUser.All to Graph Explorer and consented as admin, and double checked.
I'm running a POST against https://graph.microsoft.com/v1.0/schemaExtensions with the following payload:
{
"id":"GroupMetadata",
"description": "some desc",
"targetTypes": [
"Group"
],
"properties": [
{
"name": "groupType",
"type": "String"
}
]
}
and I'm getting the response:
{
"error": {
"code": "Authorization_RequestDenied",
"message": "Insufficient privileges to complete the operation.",
"innerError": {
"request-id": "3e3019c6-8ec5-4695-8ea3-b0aaf1ea1d25",
"date": "2017-09-06T13:14:36"
}
}
}
Any help on the matter would be appreciated.
We just deployed a fix for this. You can now Create/Update/Delete your schema definitions within Graph Explorer.
NOTE: In order to make this work you must specify the owner property to be the appId of an app that you (the signed-in user) owns, in all POST, PATCH or DELETE operations.
The documentation will be updated shortly to reflect this change. Please give it a whirl and let us know if you can now fully manage extension schema definitions through Graph Explorer.
Hope this helps,

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.

Resources