question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug]: Can't Login Via Rest API (when the same logic previously could)

See original GitHub issue

Check The Docs

  • I double checked the docs and couldn’t find any useful information.

Verify Issue Source

  • I verified the issue was caused by Discord.Net.

Check your intents

  • I double checked that I have the required intents.

Description

I have been using this lib for a while on my server (it’s amazing, thanks!) but just a few hours back I started to get this error when I try to log in to my bot. I filled in all of the details below.

Any ideas? Is this a one-off issue or a widespread issue? It looks like something might have changed in the API and now the Json deserialization is broken?

Version

3.7.2 (least)

Working Version

3.7.2 (until about 3 hours ago)

Logs

JsonSerializationException - Error converting value {null} to type 'Discord.PremiumType'. Path 'premium_type', line 1, position 348. -    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.Deserialize[T](JsonReader reader)
   at Discord.Net.Converters.OptionalConverter`1.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
onReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonSerializer.Deserialize[T](JsonReader reader)
   at Discord.API.DiscordRestApiClient.DeserializeJson[T](Stream jsonStream)
   at Discord.API.DiscordRestApiClient.SendAsync[TResponse](String method, String endpoint, BucketId bucketId, ClientBucketType clientBucket, RequestOptions options)
   at Discord.API.DiscordRestApiClient.GetMyUserAsync(RequestOptions options)
   at Discord.Rest.DiscordRestClient.OnLoginAsync(TokenType tokenType, String token)
   at Discord.Rest.BaseDiscordClient.LoginInternalAsync(TokenType tokenType, String token, Boolean validateToken)
   at Discord.Rest.BaseDiscordClient.LoginInternalAsync(TokenType tokenType, String token, Boolean validateToken)
   at Discord.Rest.BaseDiscordClient.LoginAsync(TokenType tokenType, String token, Boolean validateToken)

Sample

   m_restClient = new DiscordRestClient();
   await m_restClient.LoginAsync(Discord.TokenType.Bot, botAuthToken, true);

Packages

Discord.Net

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
quinchscommented, Jun 29, 2022

its a discord api issue, theres no point on pushing a hotfix when discord will resolve the issue themselves.

0reactions
csmircommented, Aug 1, 2022

Appears to be resolved.

Read more comments on GitHub >

github_iconTop Results From Across the Web

RESTful Login Failure: Return 401 or Custom Response
Therefore the Login API should not send a 401 response code because of a failed login attempt. It is misleading. Reasoning out that...
Read more >
How do you know what's gone wrong when your API ...
When an API request doesn't work, hopefully the client receives a sensible HTTP error status, like 409 or 500, which is a good...
Read more >
PASWS027E and ErrorMsg Object [abc_account] already exist
Add account via REST API call fails with ErrorCode: PASWS027E and ErrorMsg Object [abc_account] already exist.
Read more >
Logging the error output of a rest API
Hello. I am trying to log the errors of a consumed rest API. This error logging consists of 2 things: 1) I need...
Read more >
Getting a 401-Unauthorized Error on REST APi
I tried a direct request through cURL and it responds the same way ... REST API needs authentication and that can be achived...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found