cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frequent Visitor

"When a HTTP request is received" trigger breaks with SharePoint

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.

 

rrunnels_0-1605208342397.png

 

1 REPLY 1
Frequent Visitor

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
})

 

 

 

Helpful resources

Announcements
Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

New Super Users

Meet the Power Automate Super Users!

Many congratulations to the Season 1 2021 Flownaut Crew!

Microsoft Ignite

Microsoft Power Platform: 2021 Release Wave 1 Plan

Power Platform release plan for the 2021 release wave 1 describes all new features releasing from April through September 2021.

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Users online (11,571)