2

Is any way here to make accept Telegram.Bot.Types.Update update?

Currently, I have this code, but I would like to use Telegram objects

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

When I passing that I getting 400 Bad Request

Through Postman is 415 Unsupported Media Type and Bad request

If I hits controller by InlineKeyboard breakpoint works but with object with null values. In console (ngrok) shown 200 ok and then 400 Bad Request

Eugenia A
  • 46
  • 1
  • 6
  • does this help: https://andrewlock.net/model-binding-json-posts-in-asp-net-core/#the-new-way-in-asp-net-core – intrixius May 04 '20 at 20:53

2 Answers2

2

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

And use it on your Startup.cs file:

services.AddControllers().AddNewtonsoftJson();
0

Thanks to Robson Previato,

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

and using it in Controllers help me

services.AddControllers().AddNewtonsoftJson();

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 25 '22 at 07:49