ASP.NET 发送 multipart/form-data 到 Power Automate

ASP.NET send multipart/form-data to Power Automate

我正在尝试将 multipart/form-data 发送到 Power Automate "When a HTTP response is received" 触发操作(webhook)。

我像这样在 Postman 中生成 RestSharp 请求...

        var client = new RestClient("https://prod-122.westeurope.logic.azure.com:443/workflows/********************************/triggers/manual/paths/invoke?api-version=2016-06-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=***********************");
        client.Timeout = -1;
        var request = new RestRequest(Method.POST);
        request.AddHeader("Content-Type", "multipart/form-data");
        request.AddFile("file", @"C:\Temp\MyFile.pdf");
        IRestResponse response = client.Execute(request);
        Console.WriteLine(response.Content);

使用 Postman 发送上述内容工作正常,Power Automate 操作被触发,如 Power Automate 日志中所示。 使用 ASP.NET 网络表单发送似乎失败,即 Power Automate 日志中没有它的记录。

没有代理我在 response "The remote server returned an error: (407) Proxy Authentication Required."

中收到错误

使用代理时,我在 response "The underlying connection was closed: An unexpected error occurred on a send"

中收到错误

有什么想法吗?

意外错误与协议相关。在实例化 RestClient 之前插入以下行解决了该问题。

ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12;