Closed JackieMond closed 7 years ago
System.AggregateException was unhandled
HResult=-2146233088
Message=One or more errors occurred.
Source=mscorlib
StackTrace:
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.Wait()
at Telegram.NET.Program.Program.Main(String[] args) in \Telegram.NET.Program\Program.cs:line 24
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
HResult=-2146233088
Message=BadRequest - API_ID_INVALID
Source=Telegram.Net.Core
errorMessage=API_ID_INVALID
StackTrace:
at Telegram.Net.Core.Requests.MtProtoRequest.ThrowIfHasError() in \Telegram.Net-master\Telegram.Net.Core\Requests\MtProtoRequest.cs:line 62
at Telegram.Net.Core.TelegramClient.
Hi, Jackie. Could you please show your code how you create/initialize and use TelegramClient
?
public static void Main(string[] args) { TelegramConnect().Wait(); }
private static async Task<TelegramClient> CreateClient()
{
FileSessionStore sessionStore = new FileSessionStore();
client = new TelegramClient(sessionStore, apiId, apiHash, new DeviceInfo("Telegram Test", "Telegram Test", "Telegram Test", "en"));
clientConnected = await client.Start();
return client;
}
private static async Task<TelegramClient> TelegramConnect()
{
client = await CreateClient();
if (!client.IsUserAuthorized())
{
var codeRequest = await client.SendCode(numberToRegister, VerificationCodeDeliveryType.NumericCodeViaSms);
var hash = codeRequest.phoneCodeHash;
var code = ""; // you can change code in debugger
await client.SignIn(numberToRegister, hash, code);
}
connected = client.IsUserAuthorized() ? true : false;
return client;
}
I have same problem :(
Hi. I'll check this today in the evening. Sorry for the delay.
Ok, so:
1) About server ip addresses: you don't have to specify it. The library only needs an initial server ip address(which is currently hard-coded) and then it will automatically make an internal redirect to the correct server. So you don't need to specify your address anywhere.
2) You can have a look how DeviceInfo
is used somewhere in Tests. Here is an example:
new DeviceInfo("Telegram Test", "Telegram Test", "Telegram Test", "en")
3) About your error: BadRequest - API_ID_INVALID
This error is generated by Telegram server so it is very likely that your API ID is invalid indeed. I've checked your code with my own API ID and it worked well. If it's appropriate, you could share it with me and I'll test it(ofc, preferably somewhere in private messages).
I have same problem :(
In my Api configuration I also have the very same servers: TEST SERVER : 149.154.167.40:443 PROD SERVER: 149.154.167.50:443
With Test server(149.154.167.40:443) I get the same error as you do: API_ID_INVALID which is probably ok. But with Prod Server(149.154.167.50:443) it works just fine for me. By default TelegramClient uses 149.154.167.51 server which is one of telegram prod servers.
Did you try to specify your server address explicitly through constructor parameter in TelegramClient? (You should specify only server address without port. F.e. 149.154.167.50)
Hi, Jackie. Is it possible for you to share your apiId/hash/ips with me so that I could try to reproduce it? In private, ofc.
This error can be replicated by using new mobile numbers. Newly registered number will have a 6-digit api_id which constitutes to this error.
Ok, I'll try to register new Api and check it. Thanks for the info.
no need.. its working again.. telegram problem and they fixed it, they could not support 6 digit api_id thx for the help guys
issue solved.. you can close now 💯
Great to hear that.
Cool. Thanks for posting in this thread.
Help please, I'm trying to use Telegram.NET, I've created developer account at telegram website and got my Api ID and Api Hash so far so good.
i'm able to perform client.Start() and it returns me "connected"
after that I got to client.SendCode() and it returns me an exception which says API_ID_INVALID. i know how to copy and paste so i am pretty sure its not a number mistake..
it worked once on my friend computer when i used it without DeviceInfo so ill be glad if someone can send me an example of : DeviceInfo(string deviceModel, string systemVersion, string appVersion, string langCode)
another option is the server, in my app configuration page on telegram i get 2 servers which are different than your default server: TEST SERVER : 149.154.167.40:443 PROD SERVER: 149.154.167.50:443
tried them both but it still returns me API_ID_INVALID any suggestions ?