Skip to main content

Notifications

Community site session details
Power Automate - Building Flows
Answered

Update list item via SharePoint REST API

Like (0) ShareShare
ReportReport
Posted on 20 Apr 2020 11:22:28 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

  • Verified answer
    MichaelBoehnke Profile Picture
    23 on 22 Apr 2020 at 05:44:29
    Re: Update list item via SharePoint REST API

    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 🙂

  • MichaelBoehnke Profile Picture
    23 on 21 Apr 2020 at 18:12:25
    Re: Update list item via SharePoint REST API

    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!

  • fchopo Profile Picture
    7,968 Super User 2025 Season 1 on 21 Apr 2020 at 17:08:18
    Re: Update list item via SharePoint REST API

    Hello @MichaelBoehnke 

    I have used the following expression and it is working!

    sitePages.png

    Hope it helps!

    Ferran

  • MichaelBoehnke Profile Picture
    23 on 21 Apr 2020 at 16:56:44
    Re: Update list item via SharePoint REST API

    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
    7,968 Super User 2025 Season 1 on 21 Apr 2020 at 15:21:12
    Re: Update list item via SharePoint REST API

    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 21 Apr 2020 at 15:01:26
    Re: Update list item via SharePoint REST API

    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
    7,968 Super User 2025 Season 1 on 21 Apr 2020 at 14:41:39
    Re: Update list item via SharePoint REST API

    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 21 Apr 2020 at 13:45:58
    Re: Update list item via SharePoint REST API

    Thanks @GabrielStJohn for unblocking this topic 🙂

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Automate - Building Flows

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 18 Super User 2025 Season 1

#2
stampcoin Profile Picture

stampcoin 16

#3
Churchy Profile Picture

Churchy 12

Overall leaderboard