Hello,
I created an Azure function using this tutorial - Quickstart: Writing a PlayFab CloudScript using Azure Functions.
It works when published to Azure, but local debugging causes an error.
Local code:
PlayFabCloudScriptAPI.ExecuteFunction(new ExecuteFunctionRequest() { Entity = new PlayFab.CloudScriptModels.EntityKey() { Id = PlayFabSettings.staticPlayer.EntityId, Type = PlayFabSettings.staticPlayer.EntityType, }, FunctionName = "LoadPlayerData", FunctionParameter = new Dictionary<string, object>() { { "inputValue", "Test" } }, GeneratePlayStreamEvent = false }, (ExecuteFunctionResult result) => { if (result.FunctionResultTooLarge ?? false) { Debug.Log("This can happen if you exceed the limit that can be returned from an Azure Function, See PlayFab Limits Page for details."); return; } Debug.Log($"The {result.FunctionName} function took {result.ExecutionTimeMilliseconds} to complete"); Debug.Log($"Result: {result.FunctionResult.ToString()}"); }, (PlayFabError error) => { Debug.Log($"Opps Something went wrong: {error.GenerateErrorReport()}"); });
Server code:
[FunctionName("LoadPlayerData")] public static async Task<dynamic> Run( [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req, ILogger log) { FunctionExecutionContext<dynamic> context = JsonConvert.DeserializeObject<FunctionExecutionContext<dynamic>>(await req.ReadAsStringAsync()); dynamic args = context.FunctionArgument; var message = $"Hello {context.CallerEntityProfile.Lineage.MasterPlayerAccountId}!"; log.LogInformation(message); dynamic inputValue = null; if (args != null && args["inputValue"] != null) { inputValue = args["inputValue"]; } log.LogDebug($"HelloWorld: {new { input = inputValue } }"); return new { messageValue = message }; }
Output from local debugging:
Executed 'ExecuteFunction' (Failed, Id=0548fbfc-5141-4bc0-8a69-fd8fbbbe852a, Duration=1380ms) System.Private.CoreLib: Exception while executing function: ExecuteFunction. PlayFabAllSDK: Invalid JSON string (Parameter 'json').
Any help would be appreciated