简体   繁体   English

如何通过 webhook 获取 Telegram.Bot.Types.Update?

[英]How get Telegram.Bot.Types.Update through webhook?

Is any way here to make accept Telegram.Bot.Types.Update update?这里有什么方法可以接受 Telegram.Bot.Types.Update 更新吗?

Currently, I have this code, but I would like to use Telegram objects目前,我有这段代码,但我想使用 Telegram 对象

    [HttpPost]
    public async Task<OkResult> Post([FromBody]TelegramUpdate update) //my model
    {
        //code
    }

When I passing that I getting 400 Bad Request当我通过时,我收到 400 Bad Request

Through Postman is 415 Unsupported Media Type and Bad request通过 Postman 是 415 Unsupported Media Type and Bad request

If I hits controller by InlineKeyboard breakpoint works but with object with null values.如果我通过 InlineKeyboard 断点点击 controller 有效,但使用 object 和 null 值。 In console (ngrok) shown 200 ok and then 400 Bad Request在控制台(ngrok)中显示 200 ok 然后 400 Bad Request

Probably it's impossible, responses are in json or maybe xml formats可能是不可能的,响应是 json 或者 xml 格式

Install Nuget package "Microsoft.AspNetCore.Mvc.NewtonsoftJson"安装 Nuget package "Microsoft.AspNetCore.Mvc.NewtonsoftJson"

And use it on your Startup.cs file:并在您的 Startup.cs 文件中使用它:

services.AddControllers().AddNewtonsoftJson();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM