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 / Get SharePoint locked ...
Power Automate
Answered

Get SharePoint locked status from HTTP

(0) ShareShare
ReportReport
Posted on by 1,934 Moderator

I'm using the Send an HTTP request to SharePoint to get the name of the person who locked a file.

annetoal_0-1677257145411.png

But is there a way to use the Send an HTTP request to query if the file is locked or not?

 

Thanks,

Anne

 

Categories:
I have the same question (0)
  • Verified answer
    Expiscornovus Profile Picture
    33,768 Most Valuable Professional on at

    Hi @annetoal,

     

    There seems to be a vti_sourcecontrollockid property within the MetaInfo property of the FieldValuesAsText property everytime I lock a file. I have to do some further testing but I wanted to share my findings, it might be useful for you.

     

    Below is an example 

     

    _api/web/GetFolderByServerRelativeUrl('TestDoc')/Files('Presentation.pptx')/ListItemAllFields?$expand=FieldValuesAsText&$select=FieldValuesAsText/MetaInfo

     

    Condition expression

    outputs('Send_an_HTTP_request_to_SharePoint')?['body']['FieldValuesAsText']['MetaInfo']

    contains vti_sourcecontrollockid

     

    checkiflocked.PNG

  • annetoal Profile Picture
    1,934 Moderator on at

    @Expiscornovus ,Thank you for your response. If the file is not locked, it outputs a "null," which causes the "contains" condition to fail. As it happens, this is the same problem I had with my previous approach, which was to retrieve the SharePoint property LockedByUser. If the file is not locked, LockedByUser is null, which brings me back to the original question: How can I keep the null output from causing the contains condition to fail?

     

    Thanks,

    Anne

  • Expiscornovus Profile Picture
    33,768 Most Valuable Professional on at

    Hi @annetoal,

     

    In the example I shared you could add a second criteria to the condition and check that metainfo is not empty. Make sure that is the first criteria listed (move it up) in the condition action.

     

     

    not(empty(outputs('Send_an_HTTP_request_to_SharePoint')?['body']['FieldValuesAsText']['MetaInfo']))

     

    is equal to true

     

    checklocked.png

  • Verified answer
    annetoal Profile Picture
    1,934 Moderator on at

    @Expiscornovus Thank you for the helpful tip. I found that it worked better when I added a ['d'] in the fields and inserted the missing question marks. Here's what I finally got working:

    annetoal_0-1677790287290.png

    The condition is 

    outputs('Send_an_HTTP_request_to_SharePoint_2')?['body']?['d']?['FieldValuesAsText']?['MetaInfo']

    I really appreciate your help. The _api/web code to expand the Field Values and the existence of the vti_ values was great. 
    Thank you,

    Anne

     

  • annetoal Profile Picture
    1,934 Moderator on at

    @Expiscornovus I've been using the method you outlined in this post, and I've observed that it's not always consistent when vti_sourcecontrollockid appears in the MetaInfo field. I'm running a test where I open a Word file, then I run a flow on that file that tries to determine if the file is locked. Sometimes, contains vti_sourcecontrollid, sometimes it has this instead.

     "MetaInfo": "xxxx;#Document1 - Copy.docx;#xxxx;#\"{xxxx},1\";#\"{xxxx},2\";#0x0269B10526D4DBE0FAFC3496C557C2C7F7589AEEE8;#20791;#0\r\nvti_iplabelpromotionmoduleversion:IR|3\r\nvti_dbschemaversion:SR|16.0.333.0\r\nvti_priorversioncreationtime:TR|31 Mar 2023 15:04:02 -0000\r\nvti_timelastwnssent:TR|03 Apr 2023 16:05:10 -0000\r\n_Status:EW|\r\nvti_cobalt_NewInSession_i\\:0#.f|membership|user1@mail.edu:SW|true\r\nDocument type:EW|\r\nvti_foldersubfolderitemcount:IR|0\r\nvti_ZeroByteFileIsOverwriteable:SW|false\r\nvti_title:SW|\r\nvti_contentchangeunit:SW|\r\n_ip_UnifiedCompliancePolicyUIAction:EW|\r\nvti_iplabelpromotionversion:IW|0\r\nComments:EW|\r\n_Comments:SW|\r\nvti_streamSyncTokenSequenceNumber:IW|267\r\nvti_areHybridOrphanHashedBlobsCleaned:BW|false\r\nDept. Group:EW|\r\nDepartment owner:EW|\r\nvti_mediaserviceofficebundlegenerated:SW|TRUE\r\nvti_mediaservicemetadata:SW|{\"ctag\":\"\\\\\"c:{xxxx},26\\\\\"\",\"generationTime\":\"2023-03-31T15:09:23.3520182Z\",\"buildVersion\":\"media_prod_22709858_031623.1_03-16-2023-workerrole\",\"lastStreamUpdateTime\":\"2023-03-31T15:09:23.3520182Z\",\"modules\":[{\"module\":\"AIPLabelExtract\",\"version\":3},{\"module\":\"DocxParser\",\"version\":1},{\"module\":\"TimeToRead\",\"version\":1},{\"module\":\"OfficeBundleGeneration\",\"version\":1}],\"billedEvents\":[],\"document\":{\"language\":\"en\",\"extension\":\"docx\"},\"officeBundle\":{\"ctag\":\"\\\\\"c:{7e2de4e8-8156-4398-835c-e9104bb2ebc0},26\\\\\"\",\"fatalError\":false,\"version\":\"4.1632930951\",\"generationTime\":\"2023-03-31T15:09:23.0395164Z\",\"generationReason\":\"AnalysisPipeline\"},\"timeToRead\":0}\r\nvti_parserversion:SR|16.0.0.23515\r\nreviewComplete:BW|false\r\n_ip_UnifiedCompliancePolicyProperties:EW|\r\nreviewNotice:FX|0x01da5d78|0xb67db000\r\nvti_TimeOfLastCobaltVersionCreation:TW|31 Mar 2023 15:04:02 -0000\r\nvti_decryptskipreason:IW|1\r\n_Category:EW|\r\nreviewDue:FX|0x01da8003|0x9ee64800\r\nvti_sprocsschemaversion:SR|16.0.837.0\r\nvti_cobalt_NewInSession_i\\:0#.f|membership|user2@mail.edu:SW|true\r\nvti_modifiedby:SR|i:0#.f|membership|user2@mail.edu\r\n"

    This has led me to read more on SharePoint file locking and I've noticed that it is variable when SharePoint locks and unlocks a file, and it seems variable when SharePoint knows the name of the user who locked the file. 

    For instance, some of the time, MetaInfo contains vti_sourcecontrollockid (it thinks the file is locked), but the LockedByUser shows as null (it can't identify who locked the file).

    Also, there seems to be a delay between when you close a file and when SP detects the file is closed. And finally, there are certain files that once opened, SP never again reports them as closed. You might have to go to the extreme of copying the file contents into another file just to get a copy of the file that SP treats as unlocked.

    I was wondering if you have any similar experiences to share, or maybe commiserate with me.
    I'm still trying to get a handle on when a SP file is locked and find a consistent method to identify the locking user.
    Thanks,

    Anne 

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 251 Super User 2026 Season 1

#2
Haque Profile Picture

Haque 239

#3
Expiscornovus Profile Picture

Expiscornovus 220 Most Valuable Professional

Last 30 days Overall leaderboard