I set a button to call API (from power Automate), what should the API return if I want it shows that file download automately?

I set a button to call API (from power Automate), the API is used to Generate a PDF and there will be a "file name" and "file content".
image
I set the 'Click" like below
image

I want it shows that file download in the Form like below.
image
It is the PDF Export function in the Form.
What should the API return and the JS set in the button?
Please help.

Dear @itapps,
If you want to download PDF file on the local PC, you need to use PDF button on the form, you can configure how the results would look like with CSS - How to save SharePoint form as PDF for printing — SharePoint forms

Using Power Automate API will give you more options and control, but the files created with Power Automate cannot be downloaded instantly, they can be sent via email or uploaded to a file storage.

If you use Power Automate, the only option to download file would be to download it from this storage, for example:

  1. Start Power Automate flow and create PDF
  2. Save it to a SharePoint Document library
  3. Have a link on the form to download file from this SharePoint Document Library