EasyPost创建Webhook返回null



我试图在asp.net核心API项目中使用easy-post创建一个easy-post-webhook。它在webhook创建中返回一个null值。

我试过这个

using EasyPost;
EasyPost.ClientManager.SetCurrent("<YOUR_TEST/PRODUCTION_API_KEY>");
Webhook webhook = Webhook.Create(
new Dictionary<string, object>() {
{ "url", "https://www.foobar.com" }
}
);

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

最新更新