Inline Bot QueryResult Exception
So i found out how to respond to InlineQueries, and i can read them just fine. However, when trying to answer a query. I'm filling in the answer like this:
InlineQuery q = update.InlineQuery;
if(q != null) {
InlineQueryResult[] results = new InlineQueryResult[1];
InlineQueryResult result = new InlineQueryResultArticle();
String flipped = "Hallo";
result.MessageText = flipped;
result.Title = "Only flipped";
result.Id = flipped;
results[0] = result;
await Bot.AnswerInlineQuery(q.Id, results);
}
Only message_text, title, id and type are required, with type being article due to the InlineQueryResultArticle() constructor.
However, I get an Exception:
System.AggregateException: Mindestens ein Fehler ist aufgetreten. ---> Telegram.Bot.Types.ApiRequestException: [Error]: Bad request: Can't find field "message_text"
bei Telegram.Bot.Api.<SendWebRequest>d__78`1.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
bei System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
bei System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
bei textflip_bot.Program.<Run>d__0.MoveNext() in c:\Users\robojumper\Documents\SharpDevelop Projects\textflip_bot\textflip_bot\Program.cs:Zeile 57.
--- End of inner exception stack trace ---
bei System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
bei System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
bei System.Threading.Tasks.Task.Wait()
bei textflip_bot.Program.Main(String[] args) in c:\Users\robojumper\Documents\SharpDevelop Projects\textflip_bot\textflip_bot\Program.cs:Zeile 24.
I don't understand how the field message_text can't be found - i set it using result.MessageText = flipped; and this didn't give a compiler error. Line 57 is the await Bot.AnswerInlineQuery(q.Id, results); line. Any help would be appreciated, i probably made a dumb mistake somewhere. Also, C# is not my specialism, maybe i goofed with the dll assemblies? Is there any risk to using the wrong versions of the provided dlls?
Nevermind, I fixed it. For everyone curious,
InlineQueryResult result = new InlineQueryResultArticle();
was the bad line. The API request fails because an InlineQueryResult doesn't have a message_text field and as such, MessageText won't be serialized. The right code would be
InlineQueryResultArticle result = new InlineQueryResultArticle();
I've used a similar modified code. But the error still exists. error : Bad request: Can't find field "message_text" please advise me