I'm making an editor tool to update and read catalog items using Admin API. (this is necessary for various reasons).
Updating items:
public static void UpdateItem(ItemData data) { string titleId = PlayFabEditorDataService.SharedSettings.TitleId; string apiEndpoint = "https://" + titleId + PlayFabEditorHelper.TITLE_ENDPOINT; UpdateCatalogItemsRequest request = new UpdateCatalogItemsRequest() { Catalog = new List<CatalogItem>() { new CatalogItem(data) } }; PlayFabEditorHttp.MakeApiCall<UpdateCatalogItemsRequest, UpdateCatalogItemsResult>("/Admin/UpdateCatalogItems", apiEndpoint, request, (UpdateCatalogItemsResponse) => { Debug.Log("UpdateItem SUCCESS."); }, (PlayFabError) => { Debug.Log("UpdateItem FAIL"); }); }
This works without a problem. My ItemData is from another source and this allows me to parse it and update playfab catalog items.
Next, I would like to get the catalog items:
public static void GetItems() { string titleId = PlayFabEditorDataService.SharedSettings.TitleId; string apiEndpoint = "https://" + titleId + PlayFabEditorHelper.TITLE_ENDPOINT; GetCatalogItemsRequest request = new GetCatalogItemsRequest() { CatalogVersion = "MyCatalog" }; PlayFabEditorHttp.MakeApiCall<GetCatalogItemsRequest, GetCatalogItemsResult>("/Admin/GetCatalogItems", apiEndpoint, request, OnCatalogItemsReceived, (PlayFabError) => { Debug.Log("Get Item FAIL"); }); }
Result object (I use the same catalog item in updateitem method, it works):
public class GetCatalogItemsResult { public List<CatalogItem> Catalog { get; set; } } public class CatalogItem { public string ItemId { get; set; } public string ItemClass { get; set; } public string DisplayName { get; set; } public bool IsStackable { get; set; } public string CustomData { get; set; } public string[] Tags { get; set; } }
However, GetItems throws a null exception:
NullReferenceException: Object reference not set to an instance of an object PlayFab.PfEditor.Json.PocoJsonSerializerStrategy.DeserializeObject (System.Object value, System.Type type) (at Assets/PlayFabEditorExtensions/Editor/Scripts/PlayFabEditorSDK/SimpleJson.cs:1450)
I tried removing the customdata field, still same exception.