json64-bittelegramtdlib

API_ID error on x64 Telegram TDLIB (not x86)


I have a strange behaviour when working with the Telegram TDLIB. I've compiled TDLib for C++ Windows Library and have now the tdjson.dll for Win32 and Win64. My app is using the WIN32 version without any problem, but when I try to set TdLib parameters on the Win64 via setTdlibParameters and JSON I get the following error:

{"@type":"error","code":400,"message":"Valid api_id must be provided. Can be obtained at https://my.telegram.org"}

I even use the same JSON string as used in the WIN32 version:

{"@type":"setTdlibParameters","parameters":{"database_directory":"C:\\tdlib","use_file_database":true,"use_chat_info_database":true,"use_message_database":true,"use_secret_chats":true,"api_id":123456789,"api_hash":"5485ed51254e12547ae5555555e555d0","system_language_code":"en","device_model":"Desktop","application_version":"0.1","enable_storage_optimizer":true}}

However, I always got the invalid API_ID error with WIN64. Why is the same JSON request not working with x64 DLL version?

Any help is much appreciated.


Solution

  • My question was answered here: https://github.com/tdlib/td/issues/2211

    Starting from TDLib v1.8.6+ setTdlibParameters values must be inlined and i can see in your JSON examples you haven't inlined the parameters.

    To inline setTdlibParameters values remove the key/array parameters. So your JSON will be like:

    {
    "@type":"setTdlibParameters",
    "use_test_dc":false,
    "database_directory":"",
    "files_directory":"",
    "database_encryption_key":"",
    "use_file_database":false,
    "use_chat_info_database":false,
    "use_message_database":false,
    "use_secret_chats":false,
    "api_id":1245678,
    "api_hash":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "system_language_code":"en",
    "device_model":"Desktop",
    "system_version":"",
    "application_version":"0.1",
    "enable_storage_optimizer":false,
    "ignore_file_names":false
    }
    

    This should work fine in TDLib 1.8.6+.