question

My Game Studio avatar image
My Game Studio asked

Leaderboard Empty

My calls to the client API GetLeaderboard() is returning an empty array:

 

    {"code":200,"status":"OK","data":{"Leaderboard":[]}}

 

However, looking at the Game Manager, I can see that I have users (well, 1 user) with data for the key I requested.

 

I've checked the "Allow Client to Post Player Statistics" option under General settings.  

 

The statistic I'm querying for is the same one that my user has data for.  It's keyed under "score" and has a numeric value (currently 80).  

 

What might I be doing wrong?

 

Further info for debugging:

 

Leaderboard request:

POST https://[APP_ID].playfabapi.com/Client/GetLeaderboard

Headers omitted, but has X-Authorization header (previously obtained)

Body: {"StatisticName":"score","StartPosition":0,"MaxResultsCount":10}

Response: As above

 

UpdateUserData request:

POST https://[APP_ID].playfabapi.com/Client/UpdateUserData

Body: {"Data":{"score":80},"Permission":"Public"}

Response:

{"code":200,"status":"OK","data":{"DataVersion":6}}

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
My Game Studio avatar image
My Game Studio answered

Problem was that leaderboards are based on "Statistics", not "Data".  (Or rather, I didn't read the docs closely enough).

Switching my score reporting to use the UpdateUserStatistics endpoint (instead of the UpdateUserData one) results in a populated leaderboard.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.