I have created this azure function:
namespace FuncionRankingPrueba2 { public static class Function2 { [FunctionName("FunctionPrueba2")] public static async Task<IActionResult> Run( [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req, ILogger log) { log.LogInformation("C# HTTP trigger function processed a request."); string name = req.Query["name"]; string requestBody = await new StreamReader(req.Body).ReadToEndAsync(); dynamic data = JsonConvert.DeserializeObject(requestBody); name = name ?? data?.name; string responseMessage = string.IsNullOrEmpty(name) ? " Pass a name in the query string or in the request body" : $"Hello, {name}. This HTTP triggered function executed successfully."; return new OkObjectResult(responseMessage); } } }
And I am calling the azure function from visual studio (using Unity) with this code:
public class TestLeaderboardUpdate : MonoBehaviour { public void UpdateLeaderBoard() { PlayFabCloudScriptAPI.ExecuteFunction(new ExecuteFunctionRequest() { Entity = new PlayFab.CloudScriptModels.EntityKey() { Id = PlayFabSettings.staticPlayer.EntityId, Type = PlayFabSettings.staticPlayer.EntityType, }, FunctionName = "Prueba2Arnau", FunctionParameter = {name= "Arnau"}, GeneratePlayStreamEvent = false }, (ExecuteFunctionResult result) => { Debug.Log($"Result: {result.FunctionResult.ToString()}"); }, (PlayFabError error) => { Debug.Log($"Opps Something went wrong: {error.GenerateErrorReport()}"); }); } }
I would like the result to be:
"Hello, Arnau. This HTTP triggered function executed successfully.". For some reason the name is empty and the result is "Pass a name in the query string or in the request body". Why doesn't the azure function detects the parameter "name"?