cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Get File Content error from Form Upload

I am trying to attach files uploaded to a Form to a Jira Issue but I am getting a BadRequest error early in the flow.

 

In the activity: GET FILE CONTENT (ONEDRIVE FOR BUSINESS) the INPUTS appears to have the right URL but the OUTPUT has errors.

 

Edit-your-flow-Power-Automate (1).png

 

INPUT:

 

[{"name":"Task - Create_anonymous.png","link":"https://XXX.sharepoint.com/personal/XXX/Documents/Apps/Microsoft%20Forms/XXX%20Service%20Desk%20(2)/...","id":"01PVJRN2GDHTOVH623X5AJATRKKYPSHA3J","type":null,"size":68091,"referenceId":"01PVJRN2HRJESD53VNRJC2UKLVO2PEMZU7","driveId":"b!eoT3hbZ3lkuqSZap3wewuTey4SB5hgtFhUK-Ow0n_36D2nwVnrIXRKR_IuhRgjgY","status":1,"uploadSessionUrl":null}]

 

OUTPUT:

 

{
    "statusCode"400,
    "headers": {
        "Timing-Allow-Origin""*",
        "x-ms-apihub-cached-response""false",
        "x-ms-apihub-obo""false",
        "Date""Mon, 15 Apr 2024 12:19:00 GMT",
        "Content-Length""575",
        "Content-Type""application/json"
    },
    "body": {
        "error": {
            "code"400,
            "source""australia-001.azure-apim.net",
            "clientRequestId""fe661283-23bc-4ca0-aa65-6c2adf1962b8",
            "message""The response is not in a JSON format.",
            "innerError""<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"\"http://www.w3.org/TR/html4/strict.dtd\">\r\n<HTML><HEAD><TITLE>Bad Request</TITLE>\r\n<META HTTP-EQUIV=\"Content-Type\" Content=\"text/html; charset=us-ascii\"></HEAD>\r\n<BODY><h2>Bad Request - Invalid URL</h2>\r\n<hr><p>HTTP Error 400. The request URL is invalid.</p>\r\n</BODY></HTML>\r\n"
        }
    }
}

I then tried the Action: GET FILE CONTENT FROM PATH (ONEDRIVE FOR BUSINESS) but got this OUTPUT ERROR:

{
    "statusCode"400,
    "headers": {
        "Cache-Control""no-cache",
        "Pragma""no-cache",
        "Transfer-Encoding""chunked",
        "x-ms-request-id""29d4afed-147b-4d79-a1cc-13d4195fdb7e",
        "X-AspNet-Version""4.0.30319",
        "X-Powered-By""ASP.NET",
        "Timing-Allow-Origin""*",
        "x-ms-apihub-cached-response""false",
        "x-ms-apihub-obo""false",
        "Date""Mon, 15 Apr 2024 12:29:46 GMT",
        "Content-Type""application/json",
        "Content-Length""92",
        "Expires""-1"
    },
    "body": {
        "status"400,
        "message""Invalid request",
        "source""api.connectorp.svc.ms"
    }
}
14 REPLIES 14
Expiscornovus
Most Valuable Professional
Most Valuable Professional

Hi @Anonymous,

 

The upload question returns a string with different properties for each uploaded file. You can use a json function to convert it from a string to an array.

 

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 your Get File content action.

 

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

 



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #MicrosoftCopilotStudio content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


Anonymous
Not applicable

Hi @Expiscornovus , thank you so much for your suggestion. Before I try and implement this, will I be able to (use this ID to) actually copy or upload the file into Jira (as an attachment or comment linked to the Issue).

 

If so, I will create a new topic on how to do this. But for now I just need to know that I am heading in the right direction.

 

Use case: A Jira user should be able to open/view the attachment even though they do not have any access to the original attachment in Sharepoint*.

 

* There has been a change in that the Form now generates the attachment to a Sharepoint folder (as the Form ownership is now a Group and not an individual).

 

Anonymous
Not applicable

HI @Expiscornovus , to complicate things, I have now switched to storing the Uploads in Sharepoint.

 

So I have tried to replace the Onedrive Action with the Sharepoint Action (Get File Metadata) with the File Identifier being the UPLOAD dynamic field and the Site address being the Teams site from the drop down menu.

And I keep getting an error:

Route did not match
clientRequestId: f83a25d4-1749-497b-94be-7bfe65e0356e
serviceRequestId: f83a25d4-1749-497b-94be-7bfe65e0356e

I am so lost.

Expiscornovus
Most Valuable Professional
Most Valuable Professional

Hi @Anonymous,

 

Yes, that would be slightly different. In that case I would retrieve the path first (ServerRelativeUrl) of each upload (via a HTTP request) and use a Get File Content Using Path action instead of your Get File Metadata). 

 

Below are the steps of my proposed approach (also shared it earlier in this thread) and I also blogged about this recently with detailed steps:

https://www.expiscornovus.com/2024/02/13/retrieve-files-from-upload-file-question/

 

Below is a short snippet of that same example

 

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! 🙂

Interested in more #PowerAutomate #SharePointOnline or #MicrosoftCopilotStudio content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


Anonymous
Not applicable

Hi @Expiscornovus . Thank you so much. I checked out your blog post also. However I am getting stuck on the first step.

  1. For the 1st action "Get response details" I am forced to envelope it in an "Apply to each" which looks different from your flow which has the "Apply to each" after the "Get response details".

  2. The "Send an HTTP request to Sharepoint" is set-up as per youur instructions (see pic) but returns a Test error:

    Unable to process template language expressions in action 'Send_an_HTTP_request_to_SharePoint' inputs at line '0' and column '0': 'The template language expression 'substring(item()['link'], add(indexOf(item()['link'], 'sourcedoc=%7B'), 13), 36)' cannot be evaluated because property 'link' doesn't exist, available properties are 'webhookId, eventType, resourceData, eventTime'. Please see https://aka.ms/logicexpressions for usage details.'.

  3. I have set-up the "Get file content using path" as instructed but the Test has not yet reached that action (due to "2" above).

  4. Assuming "2" can be fixed and "3" works what else will be needed to extract the content(?) of the 1 or more attachments from the Form Upload (in Sharepoint as it is a Group Form) before it is somehow attached to the Jira Issue which is created from the same Form Response further down the flow?

    Edit-your-flow-Power-Automate (2).png
Anonymous
Not applicable

Hi @Expiscornovus . I just noticed some strikethrough text which appears to be full "Upload" Get Form Response data for when 2 files are uploaded.

 

This was discovered as the currently flow has a Create Jira Issue and simply displays the "Upload" dynamic content in the Issue description (my workaround for now).

 

Could this be a cause of the error in "2" in the previous post?

 

Screenshot 2024-04-26 140000.png

Expiscornovus
Most Valuable Professional
Most Valuable Professional

Hi @Anonymous,


Because you are already using an apply to each you would need to add another apply to each for your upload question. In your setup it should look like the below.

 

nestedapplytoeach.png



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #MicrosoftCopilotStudio content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


Anonymous
Not applicable

Hi @Expiscornovus . Thanks for the inout. I did try enveloping your bits into an additional "Apply to each 2" but I wasn't even able to Save the changes as I got this error: 

The template validation failed: 'The template action 'Apply_to_each_2' at line '1' and column '11028' is not valid: "The template function 'body' is not expected at this location.".'.

 

The json function is for the "Upload" question in the Form responses (see pics below). Is that right?

f7dbaa55-c400-42a2-a717-3aadfced8e44.png

Edit-your-flow-Power-Automate (8).png

Expiscornovus
Most Valuable Professional
Most Valuable Professional

Hi @Anonymous,

 

I see your expression uses the below format, the body function is not expected/allowed within the outputs function.

 

outputs(body())

 

 

Can you try the below format instead, just a outputs function with the body property?

 

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

 

 

or just a body without an outputs function

 

json(body('Get_response_details')?['r3bedbbeaf55e4f07808d2896d933214b'])

 

 

 



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #MicrosoftCopilotStudio content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


Anonymous
Not applicable

Hi @Expiscornovus . Thank you for your patience. I have tried both of those expressions and both enable me to save but now I am getting the same error 400 with both versions.

 

Have I got the HTTP Expressions correct (see highlighted in blue below) or am I supposed to add some dynamic content in there?

 

The Join expression:

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

The Substring expression:

substring(item()['link'], add(indexOf(item()['link'], 'sourcedoc=%7B'), 13), 36)
 
GKlose_0-1714313670171.png

 

GKlose_1-1714313710465.png

 

Test HTTP action INPUT:

GKlose_2-1714313772155.png

 

Test HTTP action OUTPUT:

 

GKlose_3-1714313816727.png

 

 

Expiscornovus
Most Valuable Professional
Most Valuable Professional

Hi @Anonymous,

 

The value within the GetFileById method looks strange. Just had another look at your uploaded files.

 

The solution I shared earlier was tested with Office files. With those you would get Office Online embedded links in the question response.  I would have to reuse the link and reuse the GUID in a HTTP request to find the direct link of each file.

 

However, in your case images/png files are used and the link property already has the correct direct link. Which makes the setup a bit easier and you don't have to use the Send an HTTP request anymore.


Try the below instead

 

Site Address

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

 

File Path 

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

 

images_uploads.png



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #MicrosoftCopilotStudio content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


Anonymous
Not applicable

Hki @Expiscornovus . Progress. The Get file content by path Action now passes the test but the Get file metadata Action fails. Do I still need it? Remember, the end game is going to uploading/attaching these files to a Jira Issue.

Inputs:

{
    "method": "get",
    "path": "/datasets/https%253A%252F%252Fsagov.sharepoint.com%252Fteams%252FmywaterProject/files/",
    "host": {
        "api": {
        },
        "connection": {
            "name": "/providers/Microsoft.PowerApps/apis/shared_sharepointonline/connections/shared-sharepointonl-41be202d-ddbf-474c-b188-c700becf6144"
        }
    },
    "authentication": {
        "scheme": "Key",
        "parameter": "*sanitized*",
        "type": "Raw"
    }
}
 
Outputs:
{
    "statusCode": 404,
    "headers": {
        "Access-Control-Allow-Methods": "GET, PUT, PATCH, DELETE, POST",
        "Access-Control-Allow-Origin": "*",
        "Access-Control-Max-Age": "3600",
        "Access-Control-Expose-Headers": "*",
        "Date": "Tue, 30 Apr 2024 10:16:26 GMT",
        "Content-Length": "54",
        "Content-Type": "application/json"
    },
    "body": {
        "statusCode": 404,
        "message": "Resource not found"
    }
}
Expiscornovus
Most Valuable Professional
Most Valuable Professional

Hi @Anonymous,

 

Like mentioned in one of my first replies, the Get File Content Using Path action is used instead of your Get File Metadata. So, you don't really need that action.



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #MicrosoftCopilotStudio content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


Anonymous
Not applicable

Hi @Expiscornovus . Got it. So I have now included the next step "Create Jira Issue" (via a Switch) inside of the same "Apply to each" as the "Get file content using path" Action and there were no errors.

 

But I am not sure what we have achieved as ultimately we want to attach the 1-3 uploaded files (in this case 2) from the Form (stored in Sharepoint) into Jira (stored in Jira).

 

When I compared the outputs of the current dynamic content of "Upload" field from the "Get response details" with the "Current content" dynamic content from "Get file content using path" I noticed that the content was in the same format (so not sure of the value in the extra step) and the "Content content" only contained 1 of the 2 uploaded links.

 

---"Upload" output---

 

[{"name":"Edit-your-flow-Power-Automate (9)anonymous 1.png","link":"https://xxx.sharepoint.com/teams/mywaterProject/Shared%20Documents/Apps/Microsoft%20Forms/xxx%20Serv...","id":"017G3RMS2OIEHWLKBP3BHJAORK5BYONBP4","type":null,"size":77850,"referenceId":"017G3RMSZZD7HXOI5QGZGJNVQMY23QOWIH","driveId":"b!Zs1iNri5kUmxF1r03HrbI1I0OTVzdL5KgVVqn1qBREvUWWNQstleQ4H8RPeLFG","status":1,"uploadSessionUrl":null},{"name":"Edit-your-flow-Power-Automate (8)_anonymous 1.png","link":"https://xxx.sharepoint.com/teams/mywaterProject/Shared%20Documents/Apps/Microsoft%20Forms/xxx%20Serv...anonymous%201.png","id":"017G3RMS6VMFGGFGPW5JH2SGDWE3OSAWVO","type":null,"size":54421,"referenceId":"017G3RMSZZD7HXOI5QGZGJNVQMY23QOWIH","driveId":"b!Zs1iNri5kUmxF1r03HrbI1I0OTVzdL5KgVVqn1qBREvUWWNQstleQ4H8R-PeLFG","status":1,"uploadSessionUrl":null}]

 

---"Current content" output---

 

{"name":"Edit-your-flow-Power-Automate (8)anonymous 1.png","link":"https://xxx.sharepoint.com/teams/mywaterProject/Shared%20Documents/Apps/Microsoft%20Forms/xxx%20Serv...","id":"017G3RMS6VMFGGFGPW5JH2SGDWE3OSAWVO","type":null,"size":54421,"referenceId":"017G3RMSZZD7HXOI5QGZGJNVQMY23QOWIH","driveId":"b!Zs1iNri5kUmxF1r03HrbI1I0OTVzdL5KgVVqn1qBREvUWWNQstleQ4H8R-PeLFG","status":1,"uploadSessionUrl":null}

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Results posted on July 24th

We are excited to announce the Summer of Solutions Challenge!    This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Community MembersNumber SolutionsSuper UsersNumber Solutions Deenuji 9 @NathanAlvares24  17 @Anil_g  7 @ManishSolanki  13 @eetuRobo  5 @David_MA  10 @VishnuReddy1997  5 @SpongYe  9JhonatanOB19932 (tie) @Nived_Nambiar  8 @maltie  2 (tie)   @PA-Noob  2 (tie)   @LukeMcG  2 (tie)   @tgut03  2 (tie)       Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 2: Community MembersSolutionsSuper UsersSolutionsPower Automate  @Deenuji  12@ManishSolanki 19 @Anil_g  10 @NathanAlvares24  17 @VishnuReddy1997  6 @Expiscornovus  10 @Tjan  5 @Nived_Nambiar  10 @eetuRobo  3 @SudeepGhatakNZ 8     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 3:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji32ManishSolanki55VishnuReddy199724NathanAlvares2444Anil_g22SudeepGhatakNZ40eetuRobo18Nived_Nambiar28Tjan8David_MA22   Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 4:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji11FLMike31Sayan11ManishSolanki16VishnuReddy199710creativeopinion14Akshansh-Sharma3SudeepGhatakNZ7claudiovc2CFernandes5 misc2Nived_Nambiar5 Usernametwice232rzaneti5 eetuRobo2   Anil_g2   SharonS2  

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (4,266)