Hi,
As mentioned on title, Why all leaderboard’s get methods returns (400) HTTP/1.1 400 Bad Request error when new player try to access the leaderboard?
When a new player opens the game for the first time, do we need to load the new player’s score data into the leaderboard?
ex: zero by default.
Besause If we dont to this we can’t access the leaderbord.
Hi @Mj-Kkaya
The user should be able to access leaderboards.
However they will not be on the leaderboards unless a score is submitted to the leaderboards.
Let me know if I misunderstood the scenario
No, I couldn’t access leaderboards.
When I delete local player data on the playerPrefs then start the Unity editor, new user can’t access the leaderboards.
For example: when I run LeaderboardsService.Instance.GetScoresAsync() method, It returns this error:
UGSLeaderboardManager-GetScores-ex:Unity.Services.Leaderboards.Exceptions.LeaderboardsException: Score submission required to view the scores of this leaderboard —> Unity.Services.Leaderboards.Internal.Http.HttpException1[Unity.Services.Leaderboards.Internal.Models.BasicErrorResponse]: (400) HTTP/1.1 400 Bad Request at Unity.Services.Leaderboards.Internal.Http.ResponseHandler.HandleAsyncResponse (Unity.Services.Leaderboards.Internal.Http.HttpClientResponse response, System.Collections.Generic.Dictionary
2[TKey,TValue] statusCodeToTypeMap) [0x0006e] in ./Library/PackageCache/com.unity.services.leaderboards@dd8c55d0e488/Runtime/com.unity.services.leaderboards.internal/Http/ResponseHandler.cs:109
at Unity.Services.Leaderboards.Internal.Http.ResponseHandler.HandleAsyncResponse[T] (Unity.Services.Leaderboards.Internal.Http.HttpClientResponse response, System.Collections.Generic.Dictionary2[TKey,TValue] statusCodeToTypeMap) [0x00001] in ./Library/PackageCache/com.unity.services.leaderboards@dd8c55d0e488/Runtime/com.unity.services.leaderboards.internal/Http/ResponseHandler.cs:226 at Unity.Services.Leaderboards.Internal.Apis.Leaderboards.InternalLeaderboardsApiClient.GetLeaderboardScoresAsync (Unity.Services.Leaderboards.Internal.Leaderboards.GetLeaderboardScoresRequest request, Unity.Services.Leaderboards.Internal.Configuration operationConfiguration) [0x001d1] in ./Library/PackageCache/com.unity.services.leaderboards@dd8c55d0e488/Runtime/com.unity.services.leaderboards.internal/Apis/InternalLeaderboardsApi.cs:351 at Unity.Services.Leaderboards.Internal.LeaderboardsServiceInternal+<>c__DisplayClass7_0.<GetScoresAsync>g__GetScoresInternal|0 () [0x00076] in ./Library/PackageCache/com.unity.services.leaderboards@dd8c55d0e488/Runtime/com.unity.services.leaderboards.internal/LeaderboardsServiceInternal.cs:95 at Unity.Services.Leaderboards.Internal.LeaderboardsServiceInternal.RunWithErrorHandling (System.Func
1[TResult] method) [0x0004f] in ./Library/PackageCache/com.unity.services.leaderboards@dd8c55d0e488/Runtime/com.unity.services.leaderboards.internal/LeaderboardsServiceInternal.cs:213
— End of inner exception stack trace —
at Unity.Services.Leaderboards.Internal.LeaderboardsServiceInternal.RunWithErrorHandling (System.Func1[TResult] method) [0x000d6] in ./Library/PackageCache/com.unity.services.leaderboards@dd8c55d0e488/Runtime/com.unity.services.leaderboards.internal/LeaderboardsServiceInternal.cs:221 at Unity.Services.Leaderboards.Internal.LeaderboardsServiceInternal.GetScoresAsync (System.String leaderboardId, Unity.Services.Leaderboards.GetScoresOptions options) [0x0007f] in ./Library/PackageCache/com.unity.services.leaderboards@dd8c55d0e488/Runtime/com.unity.services.leaderboards.internal/LeaderboardsServiceInternal.cs:99 at MjKkaya.LobbyChat.UGS.Managers.UGSLeaderboardManager.GetScores (System.String leaderboardId) [0x00039] in /Users/mjkkaya/Workspace/Tutorials/Unity/UGS/LobbyChat/Assets/LobbyChat/Scripts/UGS/Managers/UGSLeaderboardManager.cs:63 UnityEngine.Debug:Log (object) MjKkaya.LobbyChat.UGS.Managers.UGSLeaderboardManager/<GetScores>d__4:MoveNext () (at Assets/LobbyChat/Scripts/UGS/Managers/UGSLeaderboardManager.cs:68) System.Runtime.CompilerServices.AsyncTaskMethodBuilder
1<Unity.Services.Leaderboards.Models.LeaderboardScoresPage>:SetException (System.Exception)
Unity.Services.Leaderboards.Internal.LeaderboardsServiceInternal/d__7:MoveNext () (at ./Library/PackageCache/com.unity.services.leaderboards@dd8c55d0e488/Runtime/com.unity.services.leaderboards.internal/LeaderboardsServiceInternal.cs:100)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder:SetException (System.Exception)
Unity.Services.Leaderboards.Internal.LeaderboardsServiceInternal/d__15:MoveNext () (at ./Library/PackageCache/com.unity.services.leaderboards@dd8c55d0e488/Runtime/com.unity.services.leaderboards.internal/LeaderboardsServiceInternal.cs:238)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder:SetException (System.Exception)
Unity.Services.Leaderboards.Internal.LeaderboardsServiceInternal/<>c__DisplayClass7_0/<g__GetScoresInternal|0>d:MoveNext () (at ./Library/PackageCache/com.unity.services.leaderboards@dd8c55d0e488/Runtime/com.unity.services.leaderboards.internal/LeaderboardsServiceInternal.cs:96)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder1<Unity.Services.Leaderboards.Internal.Response
1<Unity.Services.Leaderboards.Internal.Models.LeaderboardScoresPage>>:SetException (System.Exception)
Unity.Services.Leaderboards.Internal.Apis.Leaderboards.InternalLeaderboardsApiClient/d__12:MoveNext () (at ./Library/PackageCache/com.unity.services.leaderboards@dd8c55d0e488/Runtime/com.unity.services.leaderboards.internal/Apis/InternalLeaderboardsApi.cs:352)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder1<Unity.Services.Leaderboards.Internal.Http.HttpClientResponse>:SetResult (Unity.Services.Leaderboards.Internal.Http.HttpClientResponse) Unity.Services.Leaderboards.Internal.Http.HttpClient/<MakeRequestAsync>d__1:MoveNext () (at ./Library/PackageCache/com.unity.services.leaderboards@dd8c55d0e488/Runtime/com.unity.services.leaderboards.internal/Http/HttpClient.cs:39) System.Runtime.CompilerServices.AsyncTaskMethodBuilder
1<Unity.Services.Leaderboards.Internal.Http.HttpClientResponse>:SetResult (Unity.Services.Leaderboards.Internal.Http.HttpClientResponse)
Unity.Services.Leaderboards.Internal.Http.HttpClient/d__3:MoveNext () (at ./Library/PackageCache/com.unity.services.leaderboards@dd8c55d0e488/Runtime/com.unity.services.leaderboards.internal/Http/HttpClient.cs:77)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder1<Unity.Services.Leaderboards.Internal.Http.HttpClientResponse>:SetResult (Unity.Services.Leaderboards.Internal.Http.HttpClientResponse) Unity.Services.Leaderboards.Internal.Http.HttpClient/<>c__DisplayClass3_0/<<CreateWebRequestAsync>b__0>d:MoveNext () (at ./Library/PackageCache/com.unity.services.leaderboards@dd8c55d0e488/Runtime/com.unity.services.leaderboards.internal/Http/HttpClient.cs:74) System.Threading.Tasks.TaskCompletionSource
1<Unity.Services.Leaderboards.Internal.Http.HttpClientResponse>:SetResult (Unity.Services.Leaderboards.Internal.Http.HttpClientResponse)
Unity.Services.Leaderboards.Internal.Http.UnityWebRequestHelpers/<>c__DisplayClass0_0:b__0 (UnityEngine.AsyncOperation) (at ./Library/PackageCache/com.unity.services.leaderboards@dd8c55d0e488/Runtime/com.unity.services.leaderboards.internal/Http/UnityWebRequestHelpers.cs:34)
UnityEngine.AsyncOperation:InvokeCompletionEvent () (at /Users/bokken/build/output/unity/unity/Runtime/Export/Scripting/AsyncOperation.cs:21)
Unity : 2022.3.1f1
Authentication : 1.0.0-exp.1
Leaderboards : 2.5.0
Thanks for sharing! your versions.
The versions seemed mixed up, I am assuming that is just a copy paste error. That means you indeed have the latest versions of AUTH 2.50 and Leaderboards 1.0.0-exp.1. I have a project in WEBGL that I can try to preproduce this. I will get back to you shortly
Hi again,
I just tested this out locally, I didn’t get the same error however I did get another error with player ID .
When clearing your player prefs do you re-initialize the authentication? I restarted the game and my player was created and was able to access the leaderboards.
I would recommend trying to re-initialize this is how I avoided the error.
PlayerPrefs.DeleteAll();
AuthenticationService.Instance.SignOut();
AuthenticationService.Instance.ClearSessionToken();
await UnityServices.InitializeAsync();
await uthenticationService.Instance.SignInAnonymouslyAsync();
Thanks for your quick response.
Actually I delete PlayerPrefs after I close the Unity editor. Then I start editor and Authentitaciton progress works correctly.
I tried your deletion way like this but Its doesn’t work.
I delete data like thiscode then restart editor but I have got same error.
When I add first score to the leaderboard then other GetPlayerScoreAsync method works correctly but it doesn’t work before run AddPlayerScoreAsync method.
PlayerPrefs.DeleteAll();
AuthenticationService.Instance.SignOut();
AuthenticationService.Instance.ClearSessionToken();
yep so the thing is if you don’t have a leaderboard created or you have created but no entries published yet I will return 404 so you’ll have to handle that. e.g. i did this when owner’s leaderboard is not published yet
Actually I created a leaderboard and there are many entries.
But when new player (player score doesn’t have in the leaderboard) try to access the that leaderboard.
I got error.
But when I add new player score to that leaderboard, after that I can access that leaderboard.
Hi MJ,
Agreed that the error message is difficult to parse, we’re currently working on making that easier to read.
The part of the error message that’s important here is Score submission required to view the scores of this leaderboard
. This tells me that you’ve configured a bucketed leaderboard, where users are assigned a bucket when they submit a score, and are ranked within that bucket and retrieve scores from that bucket. If a player hasn’t submitted a score yet, it means they haven’t yet been assigned a bucket, and so can’t retrieve scores because the service doesn’t know which bucket to read from. So in the case of bucketed leaderboards you do need to submit a score (whether that be waiting until the player has submitted a score naturally or submitting a default score) in order to retrieve leaderboard scores.
I hope this helps!
3 Likes
@devingunity your post is absolute fixed my problem.
I try to learn different Leaderboard properties like bucket and tier.
As you mentioned above, I don’t get any error when I use a different leaderboard without bucket feature.
Thanks a lot.
1 Like
It is weird, I reset leaderboard with bucket, The trigger action script always failed because “Score submission required to view the scores of this leaderboard”. is It a BUG?