Hello,
I am having a weird issue when using a Power Automate flow from Power Pages.
In trying to troubleshoot it, I tried to create a simplified example of what I am trying to achieve.
In this example, I would like to pass a json object to the cloud flow.
For the sake of this example my json object is: {"emailAddress": "user@test.com","emailBody": "Hello World"}
I have created a cloud flow that accepts a json object, parses the json to extract email and sends an email to the email address and uses the second variable for the email body.
The flow has been tested by Manually inputting the Json object and it executed successfully.
If Iaunch the flow by clicking on the button on my page, the event triggers, but I receive and error 400 (Bad Request) if I have a send email action in the flow.
If I remove the send email action in the flow, when I look at the incoming parameters as received by the first action, all is fine:
"body": {
"siteId": "'.GUID",
"siteUrl": "https://'mysite.powerappsportals.com",
"userId": "00000000-0000-0000-0000-000000000000",
"text": "{\"emailAddress\":\"user@test.com\",\"emailBody\":\"Hello World\"}"
}
Here is the code I am using:
$(document).ready(function () {
$('#i0o3hn').click(function () {
var flowUrl = "/_api/cloudflow/v1.0/trigger/0c13ec47-d97a-58f5-10b8-332e9e18809f";
var emailData = { "emailAddress": "user@test.com","emailBody": "Hello World" };
var stringifiedEmailData = JSON.stringify(emailData);
var data = {};
data["text"] = stringifiedEmailData;
console.log("data",data);
var payload = {};
payload.eventData = JSON.stringify(data);
console.log("payload:", payload);
shell
.ajaxSafePost({
type: "POST",
contentType: "application/json",
url: flowUrl,
data: JSON.stringify(payload),
processData: false,
global: false,
})
.done(function (response) {
console.log("response", response);
})
.fail(function () {
alert("failed");
});
});
});
If I was to remove the send email step of that flow and simply return the result of the parsed variables to my page, the values return correctly to the page in a console.log message.
I have attached a screenshot of the flow I am using.
Thank you.
Hi all,
Microsoft tech support confirmed that the issue was solved after a Microsoft update.
The code in my initial post works correctly now since the update.
@Atmaram90 The connection reference used to send the email is already different than the run only user. At this point I have taken the issue to Microsoft support.
@a365 Please check which connection reference (run only user) is being used for the action send email. It should not be "provided by run only user"
When the error 400 triggers, the flow does not even execute. I know it is an error 400 by looking at the console in the developer tools of the browser.
If I remove the step to send the email in the Power Automate, the flow executes fine and returns the info back to the page with a --> Return Values to Power pages action step that is in the screenshot I had in my original message. Without any changes to the code that is calling it, this is what is very weird.
If I replace the email step by an HTTP post action to an external API, all works fine, I can return the response back to power pages. If however, I was to place another step between the starting Power Pages action and the HTTP action that would perform an unbound action to read environment variable or any other type of step, it throws that error 400. My example with wanting to trigger an email message is no exception.
What happens if you copy the script provided by Microsoft and hard code your values in https://learn.microsoft.com/en-us/power-pages/configure/cloud-flow-integration#sample-javascript-to-call-a-flow
(also note: in the sample, may need to add a back slash to before the _api )
Edit: sorry didn't fully read your question, if the flow is triggering, are you sending a response back at the end of the flow? (if not try adding a Power Pages node at the end with a ->Return Values to Power pages action). Does the flow run show as a success or a failure?
Ajlan
4
Fubar
2
Super User 2025 Season 1
CBDEV
2