web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Update list item via S...
Power Automate
Unanswered

Update list item via SharePoint REST API

(0) ShareShare
ReportReport
Posted on by 23

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

Categories:
I have the same question (0)
  • MichaelBoehnke Profile Picture
    23 on at

    Thanks @GabrielStJohn for unblocking this topic 🙂

  • fchopo Profile Picture
    8,003 Moderator on at

    Hello @MichaelBoehnke 

    Have you tried to use 'type': 'SP.List' like it was a list item?

    Hope it helps!

    Ferran

  • MichaelBoehnke Profile Picture
    23 on at

    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.

  • fchopo Profile Picture
    8,003 Moderator on at

    Hello @MichaelBoehnke 

    I've tried this in my environment and it is working on a list called "Expenses":

     post.png

     

    Could you check the values are similar in your case?

    Hope it helps!

    Ferran

  • MichaelBoehnke Profile Picture
    23 on at

    Dear @fchopo, I've changed the step as per your suggestion (please note that I have thus removed the accept header)

     

    screenshot-emea.flow.microsoft.com-2020.04.21-18_44_23.png

     

    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

    flow_bad_gateway.PNG

     

    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!

  • fchopo Profile Picture
    8,003 Moderator on at

    Hello @MichaelBoehnke 

    I have used the following expression and it is working!

    sitePages.png

    Hope it helps!

    Ferran

  • MichaelBoehnke Profile Picture
    23 on at

    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!

  • Verified answer
    MichaelBoehnke Profile Picture
    23 on at

    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 🙂

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard