When trying to retrieve a leaderboard from Xbox Live, the stat event type get_leaderboard_complete
returns the error code 404. I'm using Xbox Live in a UWP game in the Creators Program.
I'm am able to set and retrieve the stat for the user. This part works without issue:
xbox_live_result<stat_value> serverStat = m_statsManager->get_stat(m_user, L"score");
auto result = serverStat.payload();
if (result.as_integer() < score) {
setStatForUser(m_user, L"score", score);
}
My code is adopted from the leaderboard example in the Xbox Live Samples. So to retrieve my leaderboard I'm calling getLeaderboard(m_user, L"score");
and every frame I'm calling statsManager->do_work();
.
// Process events from the stats manager
// This should be called each frame update
auto statsEvents = m_statsManager->do_work();
std::wstring text;
for (const auto& evt : statsEvents)
{
switch (evt.event_type())
{
case stat_event_type::local_user_added:
text = L"local_user_added";
break;
case stat_event_type::local_user_removed:
text = L"local_user_removed";
break;
case stat_event_type::stat_update_complete:
text = L"stat_update_complete";
break;
case stat_event_type::get_leaderboard_complete:
text = L"get_leaderboard_complete";
auto getLeaderboardCompleteArgs = std::dynamic_pointer_cast<leaderboard_result_event_args>(evt.event_args());
processLeaderboards(evt.local_user(), getLeaderboardCompleteArgs->result());
break;
}
stringstream_t source;
source << _T("StatsManager event: ");
source << text;
source << _T(".");
log("%S", source.str().c_str());
}
Because I'm able to set and retrieve the stat without issue, I wonder if maybe it's an issue with the Xbox Live backend? However, I'm not very familiar with the xbox live 2017 data platform, and I may be calling something incorrectly.
I discovered a solution:
I’m unsure why the original stat didn’t work. Perhaps because I used the word “score” as the statID.