cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SvenG
Helper I
Helper I

Content of x-ms-file-id header in OnNewFileV2 flow

Hi folks,

 

I'm using a OneDrive for Business trigger On New File Created V2. There is a parameter called File identifier which comes from the header value x-ms-file-id. The output is not only the file id but also the driveid in the format: driveId.fileId

Example: b!gTp3wO20k0WtUmhuonLBuXtKRm1S13RNuuhZW7LPGGO5aH4qPCLyS6EC53Jw7wdh.02TZBWRJ7XXGSLXU4BIVHL4FNAQGY2V3RH

Currently I split this string by the dot (.) to get only the fileId part. 

 

I wonder if this is correct behavior?

 

Thanks

 

3 REPLIES 3
v-alzhan-msft
Community Support
Community Support

Hi @SvenG ,

 

Could you please explain more details about your requirement?

 

Best regards,

Alice       

 

Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Alice,

 

I just need the OneDrive fileId 

 

Thanks

Sven

Automated_Flyer
New Member

Here is what I found, there is no simple way to do this as of now. Here are the two methods I leverage and what I did. I would recommend the alternative as you get more tools in your toolbox. But for a direction solution the first method would get you there:

First Method

I use the x-ms-file-id this has the path of the file that is being accessed. Be aware that '/' is '%252f' and a space (' ') is '%2b'. Due to this change in order to use anything with "using path" I had to change this. Using the replace function twice did that for me it would look something like this:

replace(replace(triggerOutputs()?['headers/x-ms-file-id'], '%252f', '/'), '%2b', ' ')

this would provide a file path from parent%252fchildFolder%252fFile%2bNeeded.txt  to parent/childFolder/File Needed.txt

Where do you put that double replace function above:

Place it into "Get file metadata using path", the result of "get file metadata using path will result in you having the FileID

Automated_Flyer_1-1649719526615.png

Alternative Method

You will also see a trigger output called 'Headers'

triggerOutputs()?['headers'] 

inside of this, it is a JSON style/formatted list of information about the file that triggered the flow. Make a compose, put headers as the input, make a file and check the running of that flow you will see what I mean. You will see there is

x-ms-file-path

. If you can separate this out with a Filter Array or Select from "Data Operations" this would be the direct path without the need for what was explained in the "First Method". While neither of them is an easy starting point, I would recommend this method, filtering and parsing JSON data is much faster and seems to be used throughout Power Automate. There are numerous explanations of the use of Filter Array and Select throughout both power users' forums.

Both methods: will work on OneDrive or OneDrive for Business.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

Top Solution Authors
Top Kudoed Authors
Users online (2,895)