Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Telegram bot api - QUERY_ID_INVALID in answerInlineQuery - Javascript

I'm trying to use answerInlineQuery method but i have an error:

function(inlineQuery) {
        var url = API_URL + '/answerInlineQuery',
            params = {};    
        var inline_query_id = inlineQuery.id;
        var results = [{
                                "type":"location",
                                "id":"1",
                                "latitude":4.710989,
                                "longitude":-74.072092,
                                "title":"Bogotá"
                              }];

        params.inline_query_id = inline_query_id;
        params.results = results;

        request('post', url, JSON.stringify(params), function(data) {
            if(data && data.ok){
                console.log('answerInlineQuery enviado');
            }else{
                console.log('Error enviando answerInlineQuery: ' + JSON.stringify(data));
            }
        });
    };

The parameters that i'm sending are (formated with JSON.stringify):

{
  "inline_query_id": "32021086267134929",
  "results": [
    {
      "type": "location",
      "id": "1",
      "latitude": 4.710989,
      "longitude": -74.072092,
      "title": "Bogotá"
    }
  ]
}

I'm using Javascript with a POST request function to the Telegram Bot API and the error that i have is this:

Error enviando answerInlineQuery: {"ok":false,"error_code":400,"description":"[Error : 400 : Bad Request: QUERY_ID_INVALID]"}

I just saw this question: telegram bot api python error but i don't know how json.dumps works in python. I need to know the correct "params" format that i need to send to the API.

like image 977
Cizaquita Avatar asked Sep 03 '26 12:09

Cizaquita


2 Answers

you should send notify max 15 sec after inline keyboard pushed

like image 99
amir Avatar answered Sep 06 '26 01:09

amir


I had 2 problems, no stringfy the "results" and stringfy the "params" that was wrong.

I just needed stringfy the "results" and not stringfy the "params"

like image 34
Cizaquita Avatar answered Sep 06 '26 02:09

Cizaquita