我尝试在asp.net核心应用编程接口项目中使用easy post创建一个easy post webhook。它在webhook创建过程中返回空值。
我试过了
using EasyPost;
EasyPost.ClientManager.SetCurrent("<YOUR_TEST/PRODUCTION_API_KEY>");
Webhook webhook = Webhook.Create(
new Dictionary<string, object>() {
{ "url", "https://www.foobar.com" }
}
);
发布于 2020-09-13 04:20:50
通过使用最新版本的C# client library,我能够让webhook create方法正确地返回JSON。这是我使用的代码片段:
using System;
using System.Collections.Generic;
using EasyPost;
using Newtonsoft.Json;
namespace create_webhook
{
class createWebhook
{
static void Main(string[] args)
{
EasyPost.ClientManager.SetCurrent(Environment.GetEnvironmentVariable("EASYPOST_API_KEY"));
Webhook webhook = Webhook.Create(
new Dictionary<string, object>() {
{ "url", "https://www.foobar.com" }
}
);
Console.WriteLine(JsonConvert.SerializeObject(webhook, Formatting.Indented));
}
}
}响应:
{
"id": "hook_123...",
"mode": "test",
"url": "https://www.foobar.com",
"disabled_at": null
}作为参考,与为C#创建webhook相关的API docs没有特别提到打印返回的内容,这就是为什么在我的示例中我添加了一个print语句。
https://stackoverflow.com/questions/53649870
复制相似问题