Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

D365 Reports DownloadPDFURL HTTP Request with Power Automate

Posted on by 873

Hello everyone,

I built a flow that will generate an SSRS report as PDF dynamically from Dynamics by following the below article:

D365 reports as PDF with Power Automate

After I have followed all the steps mentioned and performed different testing, sometimes the flow calls the API and output, as a result, the content type of the file, and sometimes it fails with the below response using the same report ID:

NotValidJSON.PNG

Inner Error returned:

""innerError": "Object moved\r\n

Object moved to here.

\r\n\r\n"

Some succeeded runs attempts (Without any changes to the flow):
HTTPSuccess.PNG

I found a workaround to handle the HTTP failure as I have added a loop to run the HTTP request in until it succeeds. I gave 10 the count of my do until it goes with every attempt a few seconds apart and it works well after 2-3 attempts and not from the first one.

FlowInputs.PNGFlowInputs2.PNG

I have also tried to add to my header Accept: application/json without the do until since it states that the response is not in JSON format but it keeps on failing. According to that post: REST API - Use the "Accept: application/json" HTTP Header - Stack Overflow

I am still troubleshoot this further how I can workaround the URL to make it compatible with JSON.

This flow really scares me as it might and might not work because I will be sending this report to our customers and I want to avoid any issue that might happen to the flow.

Kindly note that if you try to reproduce the same flow you will encounter the same issue.
I already raised the same concern to the Power Automate community that can be found here with no answer.

Any idea what will be the workaround to handle this issue and to avoid flow failure?

  would highly appreciate your input regarding the above and any help is highly appreciated.

Thank you!

  • D365 Reports DownloadPDFURL HTTP Request with Power Automate
    Hi All
     
    We have a look alike problem, but we generate a report in code.
    We have a service that should return pdf file.
    There are two stages in the process:
        * call reportviewer.aspx to receive a direct link to a pdf
        * download the pdf using the link
     
    The second stage sometimes fails: instead of the pdf we receive an html with rsExecutionNotFound error.
    Therefore to get the pdf we execute the second stage in a loop: sometimes two, sometime four iterations to succed.
    The link has sessionId and controlId.
    Our thoughts: the server that returns the link (the first stage) is not synchronized fast enough with a servers which have to return the pdf - it takes time to them to receive the sessionId and the controlId.
    It would be great if someone from Microsoft clarify that. Because it looks like a bug and does not seem to be a problem in our code or in the flow.
    Thank you.
  • RE: D365 Reports DownloadPDFURL HTTP Request with Power Automate

    Hello EBMRay, did you resolve the issue? we have the same problem.

    Regards,

    David.

  • EBMRay Profile Picture
    EBMRay 873 on at
    RE: D365 Reports DownloadPDFURL HTTP Request with Power Automate

    Hello ,

    Thank you for your prompt response.

    I replaced all '/u0026' to '&' manually in notepad and tried again with no hope.

    I will also raise a ticket with Microsoft to investigate further.

    Regards,

    EBMRay

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: D365 Reports DownloadPDFURL HTTP Request with Power Automate

    Hi EBMRay,

    I got the same error with yours when I directly copy and paste the PdfDownloadUrl to URL in the HTTP request2 as your screenshot provide.

    pastedimage1641282527082v1.png

    When I replace all '\u0026' to '&', the flow run successfully.

    Please copy and paste the PdfDownloadUrl into notepad and replace all '\u0026' to '&' first, then try again.

    If it works well, please check your the output of Step PDF Download URL in your original flow and the URL in your Http Request2.

    pastedimage1641283084263v2.png

  • EBMRay Profile Picture
    EBMRay 873 on at
    RE: D365 Reports DownloadPDFURL HTTP Request with Power Automate

    Hello   ,

    1. Yes I can download the report and it is showing the data perfectly.

    2. I copied the returned result in the response and I pasted it in the HTTP request but unfortunately I got the same issue. I compare it to my previous URL the only difference is the reportsession id and ControlID params.

    Below is a screenshot from where I got the latest URL:
    1641.TestingAPI.PNG6177.Capture.PNG

    The strangest part in my do until always it fails in the first call, then in second it succeed:
    FirstCall.PNGSecondCall.PNG

    Regards,
    EBMRay,

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: D365 Reports DownloadPDFURL HTTP Request with Power Automate

    Hi EBMRay,

    I couldn't try the URL you provide(Our base URL isn't same).

    Please check the following point:

    1.Open the corresponding report in your environment. Click the Acrobat(PDF) button. Could you download it?

    pastedimage1641280120433v1.png

    2. If you could download it well, press f12 and get the PdfDownloadUrl in the response. Compare it with the PDF URL in your flow, are them same? If not same, please copy and paste the response's PdfDownloadUrl to your flow to have a try, still got the error?

    pastedimage1641280416460v2.png

  • EBMRay Profile Picture
    EBMRay 873 on at
    RE: D365 Reports DownloadPDFURL HTTP Request with Power Automate

    Hi   ,

    No, I didn't changed anything in the flow and I have implemented the same steps as mentioned in the article but it is really strange why the flow is failing.

    I did a separate test only for the "HTTP Request 2 that GET the URL" with the below and it keeps on failing:

    TestingAPI.PNG

    /Reserved.ReportViewerWebControl.axd?ReportSession=zui5ug55lnjeir45dkv0qt45\u0026Culture=1033\u0026CultureOverrides=True\u0026UICulture=1033\u0026UICultureOverrides=True\u0026ReportStack=1\u0026ControlID=76474ac98a844dd2acdc2ab483995da9\u0026RSProxy=https://ams629srs.eur.reporting.cds.dynamics.com/reportserver\u0026OpType=Export\u0026FileName=IJCF\u0026ContentDisposition=AlwaysAttachment\u0026Format=PDF\u0026rc:PrintOnOpen=true

    I provided the above URL that I am trying to call and that's failing on. (that's based on my reportname and the other information, please try to compare it to your URL).

    Please let me know the output on your end if it works.

    Best regards,
    EBMRay

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: D365 Reports DownloadPDFURL HTTP Request with Power Automate

    Hi EBMRay,

    I followed the blog you provide and run the flow serval times. However, I couldn't reproduce the error you got. Did you change anything in the flow?

    pastedimage1641273965847v1.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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans