从ASP.Net Core App将数据发送到PowerFlow

时间:2019-12-27 17:40:58

标签: asp.net-core power-automate

我正在尝试将数据发布到Power Automate HTTP Request触发器,但是我只是获得所有具有Null值的属性。我不知道我在想什么?

要求设置“ Content-Type”:“ application / json”。 (博客发布参考:https://flow.microsoft.com/en-us/blog/call-flow-restapi/

我的.Net corre应用程序代码为:

    HttpClient client = new HttpClient();    
    client.DefaultRequestHeaders.Add("Content-Type", "application/json");
        var response = await client.PostAsJsonAsync(url, order);

        response.EnsureSuccessStatusCode();
        var data = await response.Content.ReadAsAsync<String>();

http post data

1 个答案:

答案 0 :(得分:0)

我在我这边进行测试,您可以参考下面的电源自动化流程和.net代码:

我的流程显示为: enter image description here

我的代码如下所示:

using System;
using System.Net.Http;
using System.Text;

namespace ConsoleApp7
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            var postData = "{\"name\": \"Hury\",\"email\": \"test@xxx.com\"}";
            HttpContent httpContent = new StringContent(postData, Encoding.UTF8, "application/json");

            HttpClient client = new HttpClient();
            var response = client.PostAsync("your http request trigger url", httpContent);

            Console.WriteLine(response.Result);
        }
    }
}

运行此代码后,我们可以在运行历史记录中看到属性是请求成功发布的结果。 enter image description here