I am using the following Azure Cloud Script function to reset my leaderboard. I registered the function with trigger type HTTP and created a scheduled task to run it. When I "Save and Run" the task I get the following error: "Cloud script function Reset Daily Highest Score Leaderboard returned value that was too large"
As you can see from the code, I tried to return very little... what else could be wrong?
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using PlayFab;
using PlayFab.Samples;
namespace NewYorkShowsOff.WordLace
{
public static class ResetDailyHighestScoreLeaderboard
{
[FunctionName("ResetDailyHighestScoreLeaderboard")]
public static async Task<dynamic> Run(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = null)]
HttpRequest req, ILogger log)
{
ScheduledTaskFunctionExecutionContext<dynamic> context =
JsonConvert.DeserializeObject<ScheduledTaskFunctionExecutionContext<dynamic>>(
await req.ReadAsStringAsync()
);
//var args = context.FunctionArgument;
//var lbName = args["leaderboard_name"]; // call with {"leaderboard_name" : "Daily Highest Score"}
var newRequest = new PlayFab.AdminModels.IncrementPlayerStatisticVersionRequest
{
StatisticName = "Daily Highest Score"
};
var adminApi = new PlayFabAdminInstanceAPI(
new PlayFabApiSettings
{
TitleId = context.TitleAuthenticationContext.Id
},
new PlayFabAuthenticationContext
{
EntityToken = context.TitleAuthenticationContext.EntityToken
}
);
var newResult = await adminApi.IncrementPlayerStatisticVersionAsync(newRequest);
log.LogInformation($">> ResetLB: {0}, v{1}, DeactivationTime: {2}",
newResult.Result.StatisticVersion.StatisticName,
newResult.Result.StatisticVersion.Version,
newResult.Result.StatisticVersion.DeactivationTime
);
//return new { newResult.Result };
//return new { newResult.Result.StatisticVersion };
return new {};
}
}
}