我正在尝试将数据发布到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>();
答案 0 :(得分:0)
我在我这边进行测试,您可以参考下面的电源自动化流程和.net代码:
我的代码如下所示:
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);
}
}
}