Skip to main content

Notifications

Power Automate - Building Flows
Answered

PLEASE HELP - Get file content using path error

Like (0) ShareShare
ReportReport
Posted on 31 Jan 2024 02:31:45 by 22

Hello,

 

I'm pretty new to Power Automate but it has been a day or so and I still haven't figured it out. I've looked online or YouTube and none of the solutions seemed to have worked. 

 

Essentially I have an MS Forms where users will fill out the information for approval/rejection. In that form, they will be able to add attachments (1/more). Once submitted, this will be automatically sent to the designated person for approval. At the same time, this information will be added into SharePoint Lists to see the current status of the request. Once its been approved/rejected, the approver should be able to leave comments and have the email sent back to the original requestor.

 

Currently, this is my flow:

 

cristineisles_0-1706667741507.png

cristineisles_1-1706667770139.png

cristineisles_2-1706667792025.png

 

There is a condition because depending on the requestor's answer in the form, the point of contact could vary.

 

I am running into this issue at the moment:

 

cristineisles_3-1706667910566.png

cristineisles_5-1706667976576.png

 

For Get file content using path, the path does exist

 

 

cristineisles_4-1706667942366.png

 

cristineisles_7-1706668107014.png

 

Is there a different way to work around this?

 

Do you also know how the approvers could leave a comment to be sent back to the requestor in the email?

 

  • Verified answer
    Expiscornovus Profile Picture
    Expiscornovus 31,017 on 13 Feb 2024 at 14:12:19
    Re: PLEASE HELP - Get file content using path error

    Hi @cristineisles,

     

    Thanks for confirming that it is a groups form. In that case my suggested approach would be slight different. I would retrieve the path first (ServerRelativeUrl) and use a Get File Content Using Path action instead. 

     

    Try something like below

     

    1. Add a Send an HTTP request within the attachment question apply to each loop

    a. Use as Site Address (this expression is used to retrieve the site address portion of the link)

    join(take(split(item()['link'], '/'), 5), '/')

    b. Use as URI (this expression is used to retrieve the file id portion of the link, a guid of 36 characters)

    _api/web/GetFileById('@{substring(item()['link'], add(indexOf(item()['link'], 'sourcedoc=%7B'), 13), 36)}')?$select=ServerRelativeUrl

    c. Use as Headers

    {
     "Accept": "application/json;odata=nometadata",
     "Content-Type": "application/json;odata=nometadata"
    }

     

    2. Use a Get File Content using Path instead of a Get File Content

    a. Use as Site Address

    join(take(split(item()['link'], '/'), 5), '/')

    b. Use as File Path (this expression is used to retrieve the file path portion of the ServerRelativeUrl field)

    concat('/',join(skip(split(outputs('Send_an_HTTP_request_to_SharePoint')?['body']['ServerRelativeUrl'], '/'), 3), '/'))

     

    getattachments_form.png

     

     

    Happy to help out 😁

    I share more #PowerAutomate and #SharePointOnline content on my Blog, Bluesky profile or Youtube Channel
  • cristineisles Profile Picture
    cristineisles 22 on 05 Feb 2024 at 20:12:49
    Re: PLEASE HELP - Get file content using path error

    @Expiscornovus Hello,

     

    I followed the steps above, but maybe Im still missing something. When I tried running the flow it gave me an error which said "Flow run failed". Is there a better way to re-organize my flow?


    cristineisles_0-1707163890422.png

    cristineisles_1-1707163907239.png

     

    cristineisles_2-1707163914645.png

    And yes, the forms is hosted in MS Groups, so I did use the SharePoint Get File Content

  • Expiscornovus Profile Picture
    Expiscornovus 31,017 on 05 Feb 2024 at 14:08:14
    Re: PLEASE HELP - Get file content using path error

    Hi @cristineisles,

     

    To figure out the ID for your MS Form upload question you can place a Compose action with the upload attachment question and use the peek code/code view feature of Power Automate.

     

    Btw, a MS form is normally storing the uploaded files on the OneDrive for Business site of the person who created the MS Form, that's why I suggested to use the OneDrive for Business Get File Content action.

     

    Unless it is a MS Groups hosted Form, in that case a Get File content using SharePoint might be needed.

     

    See an example below.

     

    1. Add a Compose and add your question to the Inputs.

     

    compose_codeview.png

    2. Switch the Compose to Code View to see the id of the question.

     

    questionid_codeview.png

     

     

  • cristineisles Profile Picture
    cristineisles 22 on 05 Feb 2024 at 13:49:00
    Re: PLEASE HELP - Get file content using path error

    I'm not really entirely sure how to get the URID of an MS Forms? And can I still do Get file content using SharePoint instead of OneDrive?

  • Expiscornovus Profile Picture
    Expiscornovus 31,017 on 31 Jan 2024 at 12:30:45
    Re: PLEASE HELP - Get file content using path error

    Hi @cristineisles,

     

    The answer to the question should have a list of attachments including details like the link and the guid. The trick is to convert it from a string to an array with a json function.

     

    After that you can loop through this array and retrieve the details of each item/attachment with an Apply to Each.

     

    One of those properties is the id of the file. You can use that value in a Get File content action (instead of a Get File Content using path).

     

    Below is an example

     

    1. Expression to convert string answer to array (change the id to your Forms upload attachments question id)

    json(outputs('Get_response_details')?['body/re63869bd6ae04a5683cde0c7419c6578'])

     

    2. Expression to retrieve File Id

    item()['Id']

     

    idofcurrentitem.png

     

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

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #9 Get Recognized…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 144,367

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 64,297

Leaderboard
Loading started