I'm trying to build a Flow which populates a SharePoint List from a submitted web form using When a HTTP request is received.
The flow works fantastically until I add a SharePoint Create item trigger. Then, I immediately start getting a BadRequest error on the trigger with no other explanation. I've tried rebuilding from scratch but I get the error as soon I add the Create item action.
Do I need to add some kind of authentication to the request in order to use the SharePoint connection?
Any help would be much appreciated.
I found the problem - it was an issue with jQuery in the calling code. For anyone interested:
The $.ajax() function has a dataType property that I set to "json" thinking that it would automatically set the header's content-type, but it actually only sets the data type expected in the return. The default content-type is "application/x-www-form-urlencoded".
$.ajax({
type: "POST",
url: $(this).attr("action"),
dataType: "json",
data: json_obj,
})
This worked at first, but made the properties very difficult to access in Power Automate, which should have been my first clue. Then, of course, adding a SharePoint or SQL Server connector caused the whole flow to fail with BadRequest.
To solve the problem I added a contentType property set to "application/json" and converted the payload from a json object to a string:
$.ajax({
type: "POST",
url: $(this).attr("action"),
dataType: "json",
contentType: "application/json; charset=utf-8", // Set the content-type
data: JSON.stringify(json_obj), // Stringify the output
})
Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!
Power Platform release plan for the 2021 release wave 1 describes all new features releasing from April through September 2021.
User | Count |
---|---|
14 | |
5 | |
4 | |
4 | |
4 |
User | Count |
---|---|
10 | |
8 | |
6 | |
5 | |
5 |