通过使用最新版本的C# 客户端库,我能够让 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 文档没有特别提到要打印返回的内容,这就是为什么在我的示例中添加了打印语句的原因。