The Property '__metadata' Does Not Exist on Type 'SP.Data.SPLibraryItem

Introduction

Recently, I came across a use case where the file properties need to be updated after processing the file. The business scenario here is to read the Excel file (.xlsx) from the document library and transform this data to a SharePoint list and once the process is completed, it is required to update the metadata property called ‘FileProcessed’ to ‘Yes’. By default, the value of this property is set to ‘No’ before the file processing. This ‘FileProcessed’ metadata is of type ‘Choice’ in SharePoint. The environment is SharePoint online.

According to the MSFT documentation, to work with Files and Folders in using REST API, it is required to pass header data and JSON body in a particular format. Here are the steps I have followed.

{
  "__metadata": {
    "type": "SP.Data.TailSpinLibraryItem"
  },
  "FileProcessed": "Yes"
}

The syntax is,

{
  "__metadata": {
    "type": "SP.Data.{INTERNALIBRARYNAME}Item"
  },
  "Metadata Field": "VALUE"
}

You may also refer to the screen capture below for reference for the above values mentioned in the ‘Send an HTTP request to SharePoint’ PowerAutomate action.

PowerAutomate action

Below is the error I have got.

Error

Error

  • {"odata.error":{"code":"-1, Microsoft.SharePoint.Client.InvalidClientQueryException","message":{"lang":"en-US","value":"The property '__metadata' does not exist on type 'SP.Data.DeficiencyLitigationItem'. Make sure to only use property names that are defined by the type."}}}
  • clientRequestId: 5e414111-eb3f-4ab9-94fa-7431bcffe051
  • serviceRequestId: 838954a1-90d9-6000-67a5-29234e8de6b7

Fix

Basically, the error says there is no “__metada” property existing on the data type library item. All it is required to do is remove the “__metada” JSON in the ‘Body’ and save the action. Below is the correct format for reference. Here, the metadata field's internal name should be given in double quotes, and the respective value should also be in double quotes, which is standard JSON format.

{
  "FileProcessed": "Yes"
}

HTTP Request

Once saved, and run, you should see the error go away and the required meta-data should be updated in the SharePoint library.

SharePoint library

For more information, you can refer to the official MSFT documentation in the references sections that explains REST API operations (GET, PUT, POST, PATCH, DELETE) with SharePoint lists and libraries.

Conclusion

Thus, in this article, we have seen how to update the file metadata in the SharePoint online document library using the ‘Send an HTTP request to SharePoint’ action item using Power Automate.

References


Similar Articles