这个JSON有什么问题
{"chat_id":149003957,"text":"Please Select your Language","reply_markup":{"keyboard":[[{"text":"English"},{"text":"Deutsh"}],[{"text":"Français"},{"text":"PyccKNN"}],[{"text":"Italiano"},{"text":"Espagnol"}]]}}
当作为发布请求传递给Telegram Bot API时,它会提供HTTP 400“sendMessage”
答案 0 :(得分:0)
我将您的对象发布到telegram bot API并成功接收消息。你的对象没有问题。这是我在c#中的示例代码:
private static T Call<T>(string body)
{
var contentBytes = Encoding.UTF8.GetBytes(body);
var request = (HttpWebRequest)WebRequest.Create("your bot url" + "methodName");
request.Timeout = 60 * 1000;
request.ContentLength = contentBytes.Length;
request.Method = "POST";
request.ContentType = @"application/json";
using (var requestWritter = request.GetRequestStream())
requestWritter.Write(contentBytes, 0, (int)request.ContentLength);
var responseString = string.Empty;
var webResponse = (HttpWebResponse)request.GetResponse();
var responseStream = webResponse.GetResponseStream();
using (var reader = new StreamReader(responseStream))
responseString = reader.ReadToEnd();
return JsonConvert.DeserializeObject<T>(responseString);
}