Hey im trying to simply get the Contact Email with Azure Functions. In the Azure streaming logs it says "Object reference not set to an instance of an Object". What am i doing wrong?
This is my Azure Function:
[FunctionName("DisplayEmail")] public static async Task<IActionResult> 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 apiSettings = new PlayFabApiSettings () { TitleId = context.TitleAuthenticationContext.Id, DeveloperSecretKey = Environment.GetEnvironmentVariable("PLAYFAB_DEV_SECRET_KEY", EnvironmentVariableTarget.Process) }; PlayFabAuthenticationContext titlecontext = new PlayFab.PlayFabAuthenticationContext (); titlecontext.EntityToken = context.TitleAuthenticationContext.EntityToken; var serverApi = new PlayFabServerInstanceAPI(apiSettings, titlecontext); GetPlayerProfileRequest emailRequest = new GetPlayerProfileRequest{ PlayFabId = context.CallerEntityProfile.Lineage.MasterPlayerAccountId }; PlayFabResult<GetPlayerProfileResult> emailResult = await serverApi.GetPlayerProfileAsync(emailRequest); var email = emailResult.Result.PlayerProfile.ContactEmailAddresses[0].EmailAddress; return new OkObjectResult(email); }