1

Desired Behaviour

  1. Upload file using Microsoft Forms
  2. Get file content
  3. Create new file in new location
  4. Delete original file

Actual Behaviour

I am getting error at step 2:

"body": {
    "status": 404,
    "message": "File not found\r\nclientRequestId: yadda-yadda\r\nserviceRequestId: yadda-yadda"
}

What I've Tried

In the Power Automate flow, the trigger is:

When a new response is submitted

The next action is:

Get response details

The Raw Outputs of this last action is essentially:

"body": {
    "responder": "me@domain.com",
    "submitDate": "7/5/2021 3:17:56 AM",
    "my-text-field-01":  "text string here",
    "my-file-upload-field-01":  [{.....}],
    "my-file-upload-field-02":  [{.....}],
    "my-text-field-02":  "text string here"
}

The file upload fields have this schema:

{
    "name": "My File Name_Uploader Name.docx",
    "link": "https://my-tenant.sharepoint.com/sites/my-team-site/_layouts/15/Doc.aspx?sourcedoc=%7B0F1C3107-32C9-4CEF-B4BA-87E57C9DC514%7D&file=My%20File%20Name_Uploader%20Name.docx&action=default&mobileredirect=true",
    "id": "01NSAULIQHGEOA7SJS55GLJOUH4V6J3RIU",
    "type": null,
    "size": 20400,
    "referenceId": "01NSAULISZJG7M56NSV5AIDUQFHG3BOBCH",
    "driveId": "letters-and-numbers-here",
    "status": 1,
    "uploadSessionUrl": null
}

Strangely, the id or referenceId values in this object do not correspond with the Document ID that is displayed when looking at the document's properties in the SharePoint document library:

enter image description here

Anyhow, I can target the uploaded file properties with these expressions in the flow:

json(body('Get_response_details')?['random-letters-and-numbers'])[0]['name']  
json(body('Get_response_details')?['random-letters-and-numbers'])[0]['driveId']  
json(body('Get_response_details')?['random-letters-and-numbers'])[0]['id']  

The next action I want to take is Get file content.

It seems this can be done via the following actions:

SharePoint Connectors
Get file content
Get file content using path

OneDrive for Business Connectors
Get file content
Get file content using path

I'd like to use Get file content (as it seems more dynamic than having to pass through a hardcoded path).

Several posts suggest the value I pass through to this action as the File ID should be a concatenation of driveId and id, ie:

driveId.id

Sources:
Move, rename a file submitted in a Microsoft Form
Working with files from the Forms "File Upload" question type

However, when I try the following:

enter image description here

I get the error:

"body": {
    "status": 404,
    "message": "File not found\r\nclientRequestId: yadda-yadda\r\nserviceRequestId: yadda-yadda"
}

Question

What should I be passing into Get file content as the File Identifier?

Edit 1

After reading this, perhaps File Identifier actually refers to a 'file path', ie:

/Shared Documents/Apps/Microsoft Forms/My Form Name/Question/My File Name.docx

Ergh, I tried the path above as the File Identifier (by using the UI to manually select the file) and it works - not sure how I can create it dynamically as passing in a dynamic file name does not work:

/Shared Documents/Apps/Microsoft Forms/My Form Name/Question/@{variables('file_upload_wor_document_name')}

Edit 2 The last code snippet works as File Identifier when using SharePoint's Get file content using path connector.

Would still appreciate any clarification on all the different types of id that are referred to in SharePoint/Power Automate/MS Graph etc and why driveId.id was suggested as the value to use in some places.

I am finding not having access to the relevant file id at different times is problematic, eg the Delete file action requires File Identifier to delete the file uploaded to Microsoft Forms - and I don't have access to that from the Get response details response.

user1063287
  • 10,265
  • 25
  • 122
  • 218

1 Answers1

0

You may find what you need by first getting the file metadata. When working with files uploaded through forms I sometimes use the following steps:

  1. Parse JSON for the question related to the uploaded file(s).
  2. Get File Metadata (in my example, using path)
  3. Now you have the details for doing what you want. In my example to create a table in the uploaded XLXS file for other uses.

Example: Getting file metadata from MS/Forms Upload