0

I am storing metadata with my documents and folders in SharePoint. This metadata includes an itemid which is a unique identifier from the system it came from. Is there a way to retrieve the item from SharePoint using Graph API by specifying the itemid in the metadata?

This query works for properties that Microsoft provides like name:

https://graph.microsoft.com/v1.0/sites/{siteid}/drive/root/children?$filter=name eq 'Z'

But if I try it with the custom property then I simply get an empty result:

https://graph.microsoft.com/v1.0/sites/{siteid}/drive/root/children?$filter=itemid eq 'Z'

Is there a way to query documents and folders with custom properties like this?

Here is the code used to update the field on the document in SharePoint using Graph API:

public FieldValueSet UpdateListItem(string siteId, string driveId, string fileItemId, Dictionary<string, object> additionalData)
{
    var updateFileTagsRequest = graphClient.Sites[siteId].Drives[driveId].Items[fileItemId].ListItem.Fields.Request();
    var fieldValueSet = new FieldValueSet { AdditionalData = additionalData };
    var result = updateFileTagsRequest.UpdateAsync(fieldValueSet).Result;
    return result;
}

The dictionary values being passed to the UpdateListItem method are strings and look like this: "ItemId", "A unique value"

Sigmundur
  • 725
  • 1
  • 8
  • 25
  • Could you please provide a bit more info about the field? What type of field is it? – jimas13 Jan 28 '23 at 14:11
  • It is a field that I added to the document after I created the document. It is added to the document using the AdditionalData field on the FieldValueSet. I will add the code used to update the field into the question. – Sigmundur Jan 30 '23 at 09:15
  • Could you please provide the dictionary values being passed via `additionalData`? – Cornelius J. van Dyk Feb 14 '23 at 12:52
  • @CorneliusJ.vanDyk I added it to the question. They look like this: "ItemId", "A unique value" – Sigmundur Feb 15 '23 at 13:51

0 Answers0