0

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

D365 Reports as PDF using 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:

The response is not in a JSON format

Inner Error returned:

""innerError": "<html><head><title>Object moved</title></head><body>\r\n<h2>Object moved to <a href=\"/_common/error/err.aspx?BackUri=&amp;ErrorCode=0x80040216&amp;Parm0=%0d%0a%0d%0aError%20Details%3a%20The%20report%20execution%20zui5ug55lnjeir45dkv0qt45%20has%20expired%20or%20cannot%20be%20found.&amp;RequestUri=%2fReserved.ReportViewerWebControl.axd%3fReportSession%3dzui5ug55lnjeir45dkv0qt45%26Culture%3d1033%26CultureOverrides%3dTrue%26UICulture%3d1033%26UICultureOverrides%3dTrue%26ReportStack%3d1%26ControlID%3d76474ac98a844dd2acdc2ab483995da9%26RSProxy%3dhttps%253a%252f%252fams629srs.eur.reporting.cds.dynamics.com%252freportserver%26OpType%3dExport%26FileName%3dIJCF%26ContentDisposition%3dAlwaysAttachment%26Format%3dPDF%26rc%3aPrintOnOpen%3dtrue&amp;user_lcid=1033\">here</a>.</h2>\r\n</body></html>\r\n"

Succeeded Run (Without any changes to the flow): Succeeded Run

Actions scope screenshot:

HTTP Request Screenshots

-- Updated logic to handle HTTP request: enter image description here

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.

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

Any help is highly appreciated.

EBMRay
  • 27
  • 6
  • There's an INNER ERROR there in the reponse that says "Object moved". Is there any other information in that? My suggestion would be to google that and see what comes up. The "Response is not in a JSON format" is true but it's a bum steer. The real error is the one in the "innerError" property. – Skin Jan 02 '22 at 23:49
  • Hello @Skin, Thank you for your reply. I have updated my post with the innerError returned and I already google it but did not find that someone had a similar case like mine. Maybe the issue is from the encoded URI in the URL while calling this api? – EBMRay Jan 03 '22 at 07:09
  • 1
    Interesting and looks like a tough one. I can't offer much apart from add this ... "&rs:ClearSession=True" ... to the backend of your URL and see if it helps. If that doesn't improve anything, I suggest a loop to run the HTTP request in until it succeeds. Maybe give it 10 goes with every attempt a few seconds apart or something. If it fails sporadically then that may help overcome your issue. Alternatively, raise it with Microsoft, if you can. – Skin Jan 03 '22 at 11:33
  • @Skin, I have added the mentioned URL and the flow keeps failing with the same issue. Regarding what you suggested I updated my post with the logic needed and it is really helpful and that workaround can be used until we found the right URL that should be passed to the GET method. In addition, I raised a ticket with Microsoft and I will be updating the post if they found the solution. – EBMRay Jan 03 '22 at 14:33
  • Maybe add the `Accept` header? See answer(s) here: [REST API - Use the "Accept: application/json" HTTP Header](https://stackoverflow.com/questions/43209924/rest-api-use-the-accept-application-json-http-header) – Peter Krebs Jan 03 '22 at 16:41
  • Hello @PeterKrebs, thank you for your reply. I have added Accept: application/json in the header with no hope. – EBMRay Jan 04 '22 at 07:35

1 Answers1

0

I solve this issue adding "Accept: {asterik}/{asterisk}" to the Header. sometimes the request returns the redirect error in this case try to repeat the request making the same request again(using run after setting).

fix screen