Dear community,
I am trying to set the Field "Title" in a list item to a new value by using the SP REST API. For reference, I followed the documentation about updating list items.
My update step looks like this
POST /[uri]/GetByTitle('Pages')/Items(8)
Headers
{
"If-Match": "*",
"X-HTTP-Method": "MERGE",
"Accept": "application/json;odata=verbose",
"Content-Type": "application/json"
}
Body
{
'__metadata': {
'type': 'SP.Data.PagesItem'
},
'Title': 'newTitle'
}
The response is
{
"status": 400,
"message": "The property '__metadata' does not exist on type 'SP.Data.PagesItem'. Make sure to only use property names that are defined by the type.\r\nclientRequestId: 6d32167d-5a15-44e4-8e22-0be00a17a2c9\r\nserviceRequestId: ce964a9f-b048-2000-6cd2-3e91db9c86af",
"source": "[uri]/_api/web/lists/GetByTitle('Pages')/items(8)",
"errors": [
"-1",
"Microsoft.SharePoint.Client.InvalidClientQueryException"
]
}
Strangely enough, when getting this item like so
GET [uri]/_api/web/lists/GetByTitle('Pages')/Items?$select=Id,%20Title,%20FileRef&$filter=FileRef%20eq%20%27[uri]/Pages/[pagename].aspx%27
I receive this
{
"d": {
"results": [
{
"__metadata": {
"id": "24a84d64-f9f5-42f2-b487-43048e8d5889",
"uri": "[uri]/_api/Web/Lists(guid'68025e38-a5b3-4181-be51-b3a7f737d373')/Items(8)",
"etag": "\"191\"",
"type": "SP.Data.PagesItem"
},
"Id": 8,
"Title": "[pagetitle]",
"ID": 8,
"FileRef": "[uri]/[pagename].aspx"
}
]
}
}
This shows me, that there is indeed a property '__metadata' and the type 'SP.Data.PagesItem' is also correct. So why is it not working? 🙂
Thanks for your help,
Michael
Dear @fchopo, it is working now! Turns out, I have to checkout the page first, set the title and then check it back in.
My renaming step has the following body now; as you can see the type is equal to the type of the list item
{
"__metadata": {
"type": "SP.Data.PagesItem"
},
"Title": "sdjkfslfjslfjslfjsldfjsfsdfsdfs"
}
Thanks again for your time and help 🙂
Dear @fchopo, still not working:
{
"message": "A type named 'SP.Data.SitePagesItem' could not be resolved by the model. When a model is available, each type name must resolve to a valid type.\r\nclientRequestId: 39b5278c-d39c-47f3-9b3f-cf6dd7ff32b5\r\nserviceRequestId: a3014b9f-70b0-2000-cb79-956bdc67fd31",
"status": 400,
"source": "[uri]/_api/web/lists/GetByTitle('Pages')/items(8)",
"errors": [
"-1",
"Microsoft.SharePoint.Client.InvalidClientQueryException"
]
}
This error message looks right to me, as I am trying to edit an item in list 'Pages' and not 'SitePages' as in your example. Does your example work for you when you try it for a list item in list 'Pages'? Thanks!
Dear @fchopo, I've changed the step as per your suggestion (please note that I have thus removed the accept header)
Now I get
{
"status": 400,
"message": "A type named 'SP.Data.PagesListItem' could not be resolved by the model. When a model is available, each type name must resolve to a valid type.\r\nclientRequestId: 7183eedb-5e49-4eea-abd2-5661b3b66bae\r\nserviceRequestId: c8fc4a9f-b057-2000-03d0-e9b1821e8a58",
"source": "https://[uri]/groups/653/_api/web/lists/GetByTitle('Pages')/items(8)",
"errors": [
"-1",
"Microsoft.SharePoint.Client.InvalidClientQueryException"
]
}
If I change it back now to
{
"__metadata": {
"type": "SP.Data.PagesItem"
},
"Title": "newTitle"
}
the flow just does not finish and runs forever. If I step into the running flow into this step I an see that there was at least one retry and there's an error message
I don't know if it's important, but what I am actually trying to achieve is changing the title of a classic SharePoint page (.aspx), which is under [uri]/Pages and should also be a list item of the 'Pages' list.
Thanks again!
Hello @MichaelBoehnke
I've tried this in my environment and it is working on a list called "Expenses":
Could you check the values are similar in your case?
Hope it helps!
Ferran
Hi @fchopo,
following your suggestion I've tried
{
'__metadata': {
'type': 'SP.List.ListItem'
},
'Title': '[pagetitle]'
}
This gives me:
{
"status": 400,
"message": "The property '__metadata' does not exist on type 'SP.Data.PagesItem'. Make sure to only use property names that are defined by the type.\r\nclientRequestId: 36078987-9442-43ad-b2f5-6bae7881192d\r\nserviceRequestId: a6f64a9f-800e-2000-6cd2-3be9992c4e5b",
"source": "[uri]/_api/web/lists/GetByTitle('Pages')/items(8)",
"errors": [
"-1",
"Microsoft.SharePoint.Client.InvalidClientQueryException"
]
}
so it looks like the "real" type for the list item is read and my type "SP.List.ListItem" in the request body is ignored.
This is really strange.
Hello @MichaelBoehnke
Have you tried to use 'type': 'SP.List' like it was a list item?
Hope it helps!
Ferran
Michael E. Gernaey
18
Super User 2025 Season 1
stampcoin
16
Churchy
12