1) I grant an item to the player with "GrantItemsToUserRequest"
2) After this I take from the response the ItemInstanceId to be able to immediately write some custom data to the granted equipment
3) The request is going through but the custom data doesn't appear on the item
Could you please help?
Azure function:
public static class UpdateUserInventoryEquipmentData { [FunctionName("UpdateUserInventoryEquipmentData")] 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; string itemInstanceID = args["instanceID"]; Dictionary<string, string> customData = new Dictionary<string, string> { { "equipped", "false" }, }; PlayFabSettings.staticSettings.DeveloperSecretKey = Environment.GetEnvironmentVariable("PLAYFAB_DEV_SECRET_KEY", EnvironmentVariableTarget.Process); PlayFabSettings.staticSettings.TitleId = context.TitleAuthenticationContext.Id; var authContext = new PlayFabAuthenticationContext { EntityToken = context.TitleAuthenticationContext.EntityToken }; var request = new UpdateUserInventoryItemDataRequest { ItemInstanceId = itemInstanceID, PlayFabId = context.CallerEntityProfile.Lineage.MasterPlayerAccountId, Data = customData }; return new OkObjectResult(request); } }
Unity call for the custom data update:
public void CallCloudScriptUpdateUserInventoryEquipmentData(string itemInstanceID) { PlayFabCloudScriptAPI.ExecuteFunction(new ExecuteFunctionRequest() { Entity = new PlayFab.CloudScriptModels.EntityKey() { Id = PlayFabSettings.staticPlayer.EntityId, Type = PlayFabSettings.staticPlayer.EntityType, }, FunctionName = "UpdateUserInventoryEquipmentData", FunctionParameter = new Dictionary<string, object>() { { "instanceID", itemInstanceID } }, GeneratePlayStreamEvent = true } , (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()}"); }); }
I have the CloudScript configured in PlayFab:
Azure Portal is properly set up.
After the call I get response:
{"characterId":null,"customTags":null,"data":{"equipped":"false"},"itemInstanceId":"6281XXXXXXXA2E0","keysToRemove":null,"playFabId":"82XXXXXXXX1DD","authenticationContext":null}
At the end I don't have the custom data updated in the inventory:
What am I doing wrong? Any help is appreciated.