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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Moving SharePoint list...
Power Automate
Suggested Answer

Moving SharePoint list Item to a SharePoint list Folder

(2) ShareShare
ReportReport
Posted on by 831
Trying to move a SharePoint list item into a folder in the same SharePoint list.
 
 
 
I am referencing a post I found on how to use Power Automate to complete this task:
https://michelcarlo.com/2019/03/04/microsoft-flow-how-to-move-sharepoint-online-list-items-to-folders/

 
 
Only differences I have is where I am creating a folder in my flow with an Employee's ID and my SharePoint list name is dynamic (for when I am using the production SharePoint list).
 
I am getting the error in my Send an HTTP request to SharePoint (also the MoveItem action from the post example)
 
The URL '/sites/apps/test/elrtest/Lists/LMA_Leave_Request_Test/4216/94943_.000' is invalid.  It may refer to a nonexistent file or folder, or refer to a valid file or folder that is not in the 
current Web.

SharePoint list Name: LMA_Leave_Request_Test.
SharePoint list URL: sites/apps/test/elrtest/Lists/LMA_Leave_Request_Test
SharePoint List folder: 4216
SharePoint List Item File Name: 94943_.000
SharePoint List Item's current file path: https://xxx.sharepoint.com/sites/apps/test/elrtest/Lists/LMA_Leave_Request_Test/94943_.000
Folder path to move item file to: https://xxx.sharepoint.com/sites/apps/test/elrtest/Lists/LMA_Leave_Request_Test/4216
 
 
Snippet of my Send an HTTP request to SharePoint/ MoveFile code:
I have the same question (0)
  • Suggested answer
    Haque Profile Picture
    3,653 on at
    Hi @rpersad,

    One of the idea is SharePoint doesn’t recognize item IDs as file paths! And this is the  difference between the blog you were following and and what you were expecting with item ID.  The error URL you shared (/Lists/LMA_Leave_Request_Test/4216/94943_.000) looks like you’re concatenating the item ID instead of the FileRef.

    If you can notice the blog stresses fetching FileRef and FileLeafRef before calling MoveTo.

    Add a “Send an HTTP request to SharePoint” action to get the item’s file properties:

    GET /_api/web/lists/getbytitle('LMA_Leave_Request_Test')/items(<ItemID>)?$select=FileRef,FileLeafRef

     
    Store the FileRef and FileLeafRef in  variables. Build the destination path using RootFolder + EmployeeID folder + FileLeafRef. Then Use MoveTo with FileRef:
    POST /_api/web/GetFileByServerRelativeUrl('<FileRef>')/MoveTo('<NewPath>',1)
     
    Please let me know if this helps.
     

    I am sure some clues I tried to give. If these clues help to resolve the issue brought you by here, please don't forget to check the box Does this answer your question? At the same time, I am pretty sure you have liked the response!
  • Suggested answer
    Valantis Profile Picture
    6,735 on at
     

    Your error occurs because MoveFile/MoveItem only works for files in document libraries, not list items. For a SharePoint list item, you must create it in the folder and delete the original.

     

    try this possible fix:

     

    Create item in folder using REST: POST /_api/web/lists/GetByTitle('LMA_Leave_Request_Test')/AddValidateUpdateItemUsingPath { "listItemCreateInfo": { "FolderPath": { "DecodedUrl": "/sites/apps/test/elrtest/Lists/LMA_Leave_Request_Test/4216" }, "UnderlyingObjectType": 0 }, "formValues": [ { "FieldName": "Title", "FieldValue": "YourValue" } ], "bNewDocumentUpdate": false }
     
     
    ​​​​​​​Delete original item: POST /_api/web/lists/GetByTitle('LMA_Leave_Request_Test')/items({itemId}) Headers: If-Match: *, X-HTTP-Method: DELETE
     

    If it’s a document library:

    Use Move file action in Power Automate or Graph API: PATCH ​https://graph.microsoft.com/v1.0/sites/{site-id}/drive/items/{item-id}​{ "parentReference": { "id": "{target-folder-id}" } }

     

    Source: ​https://learn.microsoft.com/graph/api/driveitem-move?view=graph-rest-1.0#http-request

     

    Best regards,

    Valantis

     

    ✅ If this helped solve your issue, please Accept as Solution so others can find it quickly.

    ❤️ If it didn’t fully solve it but was still useful, please click “Yes” on “Was this reply helpful?” or leave a Like :).

    🏷️ For follow-ups  @Valantis.

    📝 https://valantisond365.com/

     

  • rpersad Profile Picture
    831 on at
    Hi  @Haque
     
    I did use the FileRef and FileLeafRef to get the item path and new item path

    Using the HTTP Call below to get the root folder.

    GET _api/Lists/GetByTitle('LMA_Leave_Request_Test')/RootFolder
     
    Stored the root folder into the variable RootFolder, see code below:
    body('GetRootFolder')['d']['ServerRelativeUrl'] which returned the value "/sites/apps/test/elrtest/Lists/LMA_Leave_Request_Test"
     
    Using the HTTP Call below I got the FileRef and FileLeafRef.
    _api/Lists/GetByTitle('LMA_Leave_Request_Test')/Items(items('For_each')?['ID'])?$select=*,FileRef,FileLeafRef
     
    Stored the 'FileLeafRef' in the variable ItemFileName, see code below:
    body('GetItem')['d']['FileLeafRef']
    Value returned: "94943_.000"

    Stored the 'FileRef' in the variable ItemUrl, see code below:
    body('GetItem')['d']['FileRef']
    Value returned: "/sites/apps/test/elrtest/Lists/LMA_Leave_Request_Test/94943_.000"
     
    Stored new item location in the variable NewItemUrl, see code below:
    concat(variables('RootFolder'),'/',variables('varEmpID'),'/',variables('ItemFileName'))
    Value returned: "/sites/apps/test/elrtest/Lists/LMA_Leave_Request_Test/4216/94943_.000"

    HTTP Call to move file:
    POST _api/Web/getFileByServerRelativeURL('variables('ItemUrl')')/moveTo(newurl='variables('NewItemUrl')',flags=1)
  • Haque Profile Picture
    3,653 on at
     
    So, are you successful on moving  SP list item to SP list folder or still facing issue?
  • rpersad Profile Picture
    831 on at
    @Haque still having the same issue.
  • rpersad Profile Picture
    831 on at
     from the post I found and a video I also found (https://www.youtube.com/watch?v=mN_Jr8GW64g) it does seem that I have the option to using the REST api functions. 
     
    I do not want to delete the item for auditing reasons so I would not use this method. But thank you for the suggestion.
  • Suggested answer
    Haque Profile Picture
    3,653 on at
    Hi @rpersad,
     
     
    Seems you mentioned  "SharePoint List Item File Name: 94943_.000"! So the catch is "94943_.000" is an attachment file, not the list item itself. Let's do two quick things:

    1. Get the attachment file reference with the following call:

    GET _api/web/lists/GetByTitle('LMA_Leave_Request_Test')/items(<ItemID>)/AttachmentFiles

    Note: This returns the FileName and ServerRelativeUrl.

    2. Move the attachment file
    Use the MoveTo endpoint:

    POST _api/web/GetFileByServerRelativeUrl('/sites/apps/test/elrtest/Lists/LMA_Leave_Request_Test/Attachments/<ItemID>/94943_.000')/MoveTo('/sites/apps/test/elrtest/Lists/LMA_Leave_Request_Test/4216/94943_.000',1)

    Current attachment location:  '/sites/apps/test/elrtest/Lists/LMA_Leave_Request_Test/Attachments/<ItemID>/94943_.000'

    Target folder path: '/sites/apps/test/elrtest/Lists/LMA_Leave_Request_Test/4216/94943_.000'

     

  • rpersad Profile Picture
    831 on at
     
    Tried the Get the attachment file reference but it returned an empty object. 
     
     
    Copied the item path from SharePoint got back this result. Therefore I know it is not retrieving an attachment but an item. Note the number '94943' is the Item ID.
     
    Item Path: www.sharepoint.com/sites/apps/test/elrtest/Lists/LMA_Leave_Request_Test/94943_.000
  • Suggested answer
    Haque Profile Picture
    3,653 on at
    But you had mentioned it is file name earlier:
     
    If it is an item ID then we need to think differently, I doubt we can moeve an item this way.
  • Valantis Profile Picture
    6,735 on at

    Hi @rpersad,

    Just wanted to check in and see if everything is working now. If you still need any help, feel free to let me know.

    Also, if the issue is resolved, it would be great if you could mark the answer as solved so others with the same question can find it easily.

     

    Thanks and have a great day!

     

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Valantis Profile Picture

Valantis 377

#2
11manish Profile Picture

11manish 279

#3
David_MA Profile Picture

David_MA 234 Super User 2026 Season 1

Last 30 days Overall leaderboard