Telegram answerInlineQuery可以';t解析数字

本文关键字:数字 answerInlineQuery 可以 Telegram | 更新日期: 2023-09-27 18:28:57

我正在开发一个名为InlineQuery的带有Telegram bot API新功能的机器人,我在C#中实现了所有类型,现在可以将查询从Telegram返回到我的机器人,当我试图回答我在Json下面发布的查询到Telegram answerInlineQuery方法时,我得到了这个错误:

"错误的请求:无法解析json编码的内联查询结果:[错误]:无法解析数字"

{"inline_query_id":"515050766530700016","results":[{"type":"photo","photo_url":"http://weknowyourdreams.com/images/car/car-05.jpg","photo_width":0,"photo_height":0,"description":"wrdqw","caption":"wer","id":"46156165165","title":"123","message_text":"123","parse_mode":"Markdown","thumb_url":"http://weknowyourdreams.com/images/car/car-05.jpg","disable_web_page_preview":false}],"cache_time":300,"is_personal":false,"next_offset":"0"}

这是我根据本文档构建的AnswerInlineQuery的结构:https://core.telegram.org/bots/api#answerinlinequery

public class AnswerInlineQuery
{
    public string InlineQueryId { get; set; }
    public List<InlineQueryResult> Results { get; set; }
    public int CacheTime { get; set; }
    public bool IsPersonal { get; set; }
    public string NextOffset { get; set; }
}

和"InlineQueryResult":

public class InlineQueryResult
{
    public string Id { get; set; }
    public string Title { get; set; }
    public string MessageText { get; set; }
    public string ParseMode { get; set; }
    public string ThumbUrl { get; set; }
    public bool DisableWebPagePreview { get; set; }
}

和"InlineQueryResultPhoto":

public class InlineQueryResultPhoto : InlineQueryResult
{
    public string Type => "photo";
    public string PhotoUrl { get; set; }
    public int PhotoWidth { get; set; }
    public int PhotoHeight { get; set; }
    public string Description { get; set; }
    public string Caption { get; set; }
}

我尝试传递这样的空结果:

Bot.AnswerInlineQuery(new AnswerInlineQuery
{
    InlineQueryId = inlinequery.Id,
    Results = new List<InlineQueryResult>(),
    IsPersonal = false,
    CacheTime = 300,
    NextOffset = "0"
});

但我又犯了同样的错误,似乎问题不在"结果"!

我不知道这意味着什么数字,并用许多不同的数据试用Json,但我无法修复它,我的Json结构错了吗?知道吗?

谢谢。

Telegram answerInlineQuery可以';t解析数字

问题解决了,结果参数必须是字符串变量包含Json数组的结果不完全是Json数组:

results = new RestRequest().JsonSerializer.Serialize(answer.Results)