From 7420b2855a0d431d08a3e6ee666409cb5eb289d5 Mon Sep 17 00:00:00 2001 From: Wizou <11647984+wiz0u@users.noreply.github.com> Date: Mon, 24 Jun 2024 21:24:37 +0200 Subject: [PATCH] Added STJ info --- src/FAQ.md | 4 +++- src/Migration-Guide-to-Version-21.x.md | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/FAQ.md b/src/FAQ.md index 86713ae..eab5cf0 100644 --- a/src/FAQ.md +++ b/src/FAQ.md @@ -21,7 +21,9 @@ Check the `UpdateType` of the `Update`. If it is `UpdateType.ChannelPost` then t ## I have serialization issues or null values in `Update` object in my webhook. What do I do? -If you're using ASP.NET Core 3.0+ you need to install additional Nuget package: [Microsoft.AspNetCore.Mvc.NewtonsoftJson](https://www.nuget.org/packages/Microsoft.AspNetCore.Mvc.NewtonsoftJson/). For more information read [this page](https://docs.microsoft.com/en-us/aspnet/core/migration/22-to-30?view=aspnetcore-3.1&tabs=visual-studio#use-newtonsoftjson-in-an-aspnet-core-30-mvc-project) about migrating from previous versions of ASP.NET Core. +If you're using ASP.NET Core 3.0+ you need to configure System.Text.Json options to work correctly with Telegram.Bot + +See [this page for instructions](Migration-Guide-to-Version-21.x.md#webhooks-with-systemtextjson). ## Is there a way to get a list of users in a group or a channel? diff --git a/src/Migration-Guide-to-Version-21.x.md b/src/Migration-Guide-to-Version-21.x.md index df7cd23..d97c7ca 100644 --- a/src/Migration-Guide-to-Version-21.x.md +++ b/src/Migration-Guide-to-Version-21.x.md @@ -71,3 +71,13 @@ To make a payment in [Telegram Stars](https://t.me/BotNews/90) with SendInvoiceA - `prices:` with a single price - no tip amounts +## Webhooks with System.Text.Json + +The library now uses `System.Text.Json` instead of `NewtonsoftJson`. + +To make it work in your ASP.NET projects, you'll need to: +- Remove package **Microsoft.AspNetCore.Mvc.NewtonsoftJson** from your project dependencies +- Configure your webapp services in your Startup with +`services.ConfigureTelegramBot(opt => opt.JsonSerializerOptions);` +- or if you use minimal APIs, use this line instead: +`builder.Services.ConfigureTelegramBot(opt => opt.SerializerOptions);`