Graph API - Update SharePoint Library Fields after Drive Upload - microsoft-graph-api

I am uploading files via the Microsoft Graph Rest API for SharePoint Online. I am leveraging the Drive Upload API to push files into a document library but I am not seeing a easy method to set field values on a file after or during the upload. Reviewing the API documentation, it appears you can leverage the List API to update/set fields, but you have to first find the id of the list object (file) and then perform the patch to update the fields. I am curious if there is a method that uses the file Id or some other tag I get from the upload to easily set field values?
I am leveraging the following for uploads:
PUT /sites/{site-id}/drive/items/{parent-id}:/{filename}:/content
It appears I need to find the new file I uploaded by name, then patch the fields I want set:
GET https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items
PATCH https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items/{item-id}/fields
Post Answer Edit:
You can get the List ID value by going through the relationship of the drive object.
GET /sites/{site-id}/drive/items/{item-id}/ListItem

An item in a SharePoint document library is a linked item consisting of the DriveItem and the ListItem. Your PUT-Request returns the created DriveItem. Each DriveItem has a property called listItem, which contains the linked ListItem.
You can use the property id of the linked listItem to update the item directly without searching for the ListItem. First, upload the document and wait for the response:
var driveItem = PUT /sites/{site-id}/drive/items/{parent-id}:/{filename}:/content
Next, get the item id of the ListItem:
var listItemId = driveItem.ListItem.Id
Then, update the ListItem:
PATCH https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items/{listItemId}/fields
So far, I have not come across an easier way to do this.

Related

Can't retrieve outlook add-in custom properties from graph API

I need to save a custom property from my outlook add-in and retrieve the this value from graph Api.
I followed MS documentation, this link and this one.
I store the custom property with office.js methods loadCustomPropertiesAsync and customProps.saveAsync
I have checked the value is correctly stored to custom properties (I can read it from add-in when I come back to event)
When I try to check the value from graph API, the event is returned without custom props.
here is the request I use :
{{endpoint}}/Users/bc2d0290-xxx-4041d2d39b66/Events/AAMkADI1YTJjZTI1LWM4YjUtNxxxTvAAA=?$expand=singleValueExtendedProperties($filter=id eq 'String {00020329-0000-0000-C000-000000000046} Name cecp-myAddInManifestId')
What am I doing wrong ?
I found my mistake.
I use custom properties to enrich appointements with conference room.
I tried to retrieve custom props on my server from room eventId instead of organizer eventId

Microsoft Graph API: How to use Get Call Method?

I'm using the Microsoft Graph API to retrieve information about Microsoft Teams.
Now i want to retrieve information about the call using the method in the documentation below:
https://learn.microsoft.com/en-us/graph/api/call-get?view=graph-rest-1.0&tabs=http
Here is written that i have to use the following url:
GET /communications/calls/{id}
The thing is that i don't know what is the id i need to use because in the documentation is not specified.
I try to use the group id, channel id and personal id of Teams but none of them works. Somebody knows how to use this method?
Thanks
See Properties of call resource type, id is the call id. Read-only.
When you create a call, you will get an id in the response. see the response sample.
When you need to get the call, just put this id value into GET https://graph.microsoft.com/v1.0/communications/calls/{id}.

Microsoft Graph fails when updating orderHint for a Planner bucket

I'm trying to update a Planner bucket's order. To do that, I set the orderHint value of that bucket to be <prevBucketOrderHint> <nextBucketOrderHint>!. This is the only change I make to the bucket object, however, when I try to save the changes, I get the following error:
Validation for field 'PlanId', on entity 'Bucket' has failed: This field is read only and cannot be changed
However, I'm not accessing nor modifying value of PlanId and therefore I don't understand why I get this error.
Below you can find the code I use to achieve my task (note that this is a C# code using the SDK and variable gc is a valid instance of Microsoft.Graph.GraphServiceClient):
theBucket.OrderHint = string.Format("{0} {1}!", previousBucket.OrderHint, nextBucket.OrderHint);
var etag = theBucket.GetEtag();
var result = gc.Planner.Buckets[bucketId].Request().Header("If-Match", etag).UpdateAsync(theBucket).Result;
Do you see any mistake in my approach or, alternatively, do you have any suggestions on how to change the order of buckets in a Planner plan?
Thanks
I'm guessing that you got theBucket object as the result of another call. The API endpoint expects a patch object that only contains the properties you want to update. You are sending the existing object as the patch object. The existing object theBucket has the planId set which is read-only at the service.
Fix it by creating a new PlannerBucket and only set the OrderHint property on it. Use the new PlannerBucket in the UpdateAsync method.

How to get the end screen element with an end_screen_element_id from Youtube API

With a channel reporting job, we can get the end_screen_element_ids for a given video. These IDs look like GUIDs.
The question is : How do we query the Youtube API to get what video/channel/... these end_screen_element_ids points to ?
Thanks!
You may use the reportTypes.list method. This returns a list of report types that the channel or content owner can retrieve. Each item in the list contains an id property, which identifies the report's ID, and you need this value to schedule a reporting job.

Can't add description to OneDrive folders

I'm posting a create item http request the to the graph api ("\children") to create a folder under a groups files, but I'm getting the following error:
"code": "-1, Microsoft.SharePoint.Client.InvalidClientQueryException",
"message": "The property 'description' does not exist on type 'oneDrive.item'.
Make sure to only use property names that are defined by the type."
It does not allow description to be part of the the request body json, even though the documentation says it is a read-write property on the item type.
Please help anyone!?:) The description field could be really valuable to store additional info about a folder or file.
The description property isn't support for OneDrive for Business right now, which is why this call fails. If you create a folder without the description property the call should succeed. I've made updates to the documentation to remove the description property from the docs until it's supported for OneDrive for Business.

Resources