Closed a-a-k closed 8 years ago
which ID do you use for the inlineQueryId
parameter when you call AnswerInlineQuery
? The error message sounds more like something related to that id.
What version do you use?
I use update.InlineQuery.Id
and 8.1.0 version of NuGet package.
Can you try the latest beta? with api 2.0 there were many changes, don't know how much this effects this case...
ok
Allright,
now getting the next errors
[Error : 400 : Bad request: Can't find field "message_text"]
or
[Error : 400 : Bad request: Field "thumb_width" must be of type Number]
or
[Error : 400 : Bad request: Field "thumb_height" must be of type Number]
or again
[Error : 400 : Bad Request: QUERY_ID_INVALID]
InlineQueryResultArticle
requires the property InputMessageContent
, that's the Can't find field "message_text"
error.
I receive [Error : 400 : Bad Request: QUERY_ID_INVALID]
if I delay the response by 8-10 seconds. But can't find anything in the docs about some timeout.
I receive [Error : 400 : Bad Request: QUERY_ID_INVALID] if I delay the response by 8-10 seconds. But can't find anything in the docs about some timeout.
Robin, I got the next answer from Bot Support:
Hi, inline queries require a fast answer, if the answer is delayed, you may get that error and the answer won't be valid. I suggest you to answer faster to them in order to make them work.
May be need catch this exception and simply do nothing in catch body? Like here catch (TaskCanceledException) { }
for example.
So, how is it? I can't send results via AnswerInlineQuery because I receive the same "Bad Request: QUERY_ID_INVALID". I am using ver. 9.0.0 from NuGet. Should I switch to beta ver. or something?
how long does your code take to answer the query?
I had the same issue when I was implementing my inline query. Basically when an user starts to write the query Telegram keep asking your bot to process a query. every new character the user write, Telegram send a request with the new query, making the older one invalid.
I resolved creating a list of "current users that are using inline query". When they start writing I add them to list, and when i receive a new query I see if they were already waiting for an answer to an old query. if they do, i invalidate the old request, and start the new one. If they are not in list, i add them and start the request.
This usually happen when the request answers in more time the user take to add another character to his query and start another request.
Hope is clear enough
Hi I am getting the correct response after doing some POC. I am using java com.github.pengrad. below the code.
GetUpdatesResponse updatesResponse = bot.execute(new GetUpdates());
List<Update> updates = updatesResponse.updates();
for(Update update:updates){
InlineQuery inlineQuery = update.inlineQuery();
System.out.println(update);
System.out.println(inlineQuery);
System.out.println("----------------");
if(inlineQuery!=null) {
InlineQueryResult r1 = new InlineQueryResultPhoto("AgADBQADrqcxG5q8tQ0EKSz5JaZjzDWgvzIABL0Neit4ar9MsXYBAAEC", "https://api.telegram.org/file/bot230014106:AAGtWr8xUCqUy8HjSgSFrY3aCs4IZs00Omg/photo/file_1.jpg", "https://api.telegram.org/file/bot230014106:AAGtWr8xUCqUy8HjSgSFrY3aCs4IZs00Omg/photo/file_1.jpg");
BaseResponse baseResponse = bot.execute(new AnswerInlineQuery(inlineQuery.id(), r1)
.cacheTime(6000)
.isPersonal(true)
.nextOffset("offset")
.switchPmParameter("pmParam")
.switchPmText("pmText"));
System.out.println(baseResponse.isOk());
System.out.println(baseResponse.toString());
System.out.println(baseResponse.description());
}
}
below the console output:
Update{update_id=465103212, message=null, edited_message=null, inline_query=InlineQuery{id='995145139265927135', from=User{id=231700283, first_name='Manabendra', last_name='Maji', username='null'}, location=null, query='hi', offset=''}, chosen_inline_result=null, callback_query=null}
InlineQuery{id='995145139265927135', from=User{id=231700283, first_name='Manabendra', last_name='Maji', username='null'}, location=null, query='hi', offset=''}
----------------
true
BaseResponse{ok=true, error_code=0, description='null'}
null
And I am getting proper response in my mobile telegram app also.
hi you must answer InlineQuery and CallbackQuery until 15 seconds. after that recive QUERY_ID_INVALID
I tested it and I got an error exactly after 10 seconds delay. So you have to reply within 10 seconds
THANK YOU! @abadakhshan and @karb0f0s This was driving me mad trying to figure out why it wasn't working with any of the ID's. I had to do it right away (<10 seconds).
I'm getting this same error even though I'm answering the query in less than 2 seconds. The data I'm trying to POST back is
{
inline_query_id: '216443202',
results: '[{"type":"article","id":"1533502232641_0","title":"Test Result","input_message_content":{"message_text":"This was a triumph","parse_mode":"Markdown"}}]'
}
The ID I'm using is the ID of the incoming query. I've no idea what else to try at this point. Google only points me to more solutions regarding the timeout of the reply.
Wanna add my weight here to @lopis . I'm facing the same problem although my query is answered in blazing speeds, (<2 seconds). Any answer APART from suggesting timeouts will be greatly appreciated.
I've solved my problem. What worked was to stringify my payload.
@lopis your "results" is currently a STRING. results are supposed to be an ARRAY. Perhaps you can try editing this to see if it works. Cheers!
Quick addition as this issue comes up in googe:
This can also be because some InlineQueryResult
's (e.g. InlineQueryResultArticle
) id
field being more than 64
characters.
I am getting this error on both ways of asign value to ID property. It's so strange that this exception throwed after the different sequence of operations from time to time. Is it known problem or I'm doing something wrong?