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

502 bad gateway connecting Flow to SharePoint 2016 on premise


I am trying use Flow on our SharePoint 2016 on premise instance. So I built  an On premise data gateway, this part is rather simple and well explained even behind a proxy. I have left the default https connection enabled. So the connection report is fine and I was able to create a connection in Flow > Gateways.


But when I test a simple trigger like when files added in SharePoint I receive and 502 error :

"error": {
"code": 502,
"source": "",
"clientRequestId": "b36ccb60-23fd-4ba9-b831-dbb96209c739",
"message": "BadGateway",
"innerError": {
"message": "Received error payload from gateway service with ID 33707: Substituted: HttpRequestException:<pi>System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel. ---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure.\r\n at System.Net.TlsStream.EndWrite(IAsyncResult asyncResult)\r\n at System.Net.ConnectStream.WriteHeadersCallback(IAsyncResult ar)\r\n --- End of inner exception stack trace ---


It looks like flow Flow tries to connect to the SharePoint site without success. It can be simple connection error or and an SSL error. It all depends on how Flow make resolves the name and makes the http call. Is it through the gateway or internet ?

Our SharePoint is not accessible from outside our LAN, so do we have to just add a dns record or go further with azure application proxy ?


Thanks for any suggestion ,

Jean Marie

Community Support
Community Support



How did you create a connection to SharePoint On-premises?

Please make sure you followed the steps suggested in the following blog:

Further, if the Site address is not listed under the dropdown selections, please enter the correct site address manually by clicking the Enter custom value. Please take a try with it.

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

HI @v-litu-msft ,


I did follow the mentioned link to create the connection and also manually add the site address and folder. Of course I have selected my on prem connection in the option of the stage.



yesterday after a while and adding a / at the end of the url, the error message went away. It is not the case today where the error says We cannot find the site address.

So back to my question : how do Flow resolve the name of my SharePoint site ? It seems that it uses a simple DNS search.

If it is the case, then does Flow needs to authenticate to the site using a standard http connection instead of the gateway ?




Ok, you can have a try to use the Send an http request to SharePoint action get files in SharePoint:

You can refer to this blog, it collect some methods how to call SharePoint in MS Flow, hope some will help:

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (1,093)