首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >EasyPost Create Webhook返回null

EasyPost Create Webhook返回null
EN

Stack Overflow用户
提问于 2018-12-06 18:57:29
回答 1查看 177关注 0票数 0

我尝试在asp.net核心应用编程接口项目中使用easy post创建一个easy post webhook。它在webhook创建过程中返回空值。

我试过了

代码语言:javascript
复制
using EasyPost;
EasyPost.ClientManager.SetCurrent("<YOUR_TEST/PRODUCTION_API_KEY>");

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

EN

回答 1

Stack Overflow用户

发布于 2020-09-13 04:20:50

通过使用最新版本的C# client library,我能够让webhook create方法正确地返回JSON。这是我使用的代码片段:

代码语言:javascript
复制
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));
        }
    }
}

响应:

代码语言:javascript
复制
{
  "id": "hook_123...",
  "mode": "test",
  "url": "https://www.foobar.com",
  "disabled_at": null
}

作为参考,与为C#创建webhook相关的API docs没有特别提到打印返回的内容,这就是为什么在我的示例中我添加了一个print语句。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53649870

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档