question

Bryan Matsui Pierce avatar image
Bryan Matsui Pierce asked

EntityProfileVersionMismatch when calling GetObjects and InitiateFileUploadsRequest

I am trying to upload Entity Objects and Files at the same time but keep encountering an EntityProfileVersionMismatch error. Here is a truncated version of the code that I am using:

 static readonly EntityKey Key = new EntityKey() {
             Id = "-------",
             Type = "title_player_account"
         };
         static void TestFunc() {
             SetObjectsRequest objectsRequest = new SetObjectsRequest() {
                 Objects = new List<SetObject>() {
                     new SetObject() {
                         ObjectName = "object_4",
                         DataObject = "test"
                     }
                 },
                 Entity = Key,
                 ExpectedProfileVersion = null
             };
             InitiateFileUploadsRequest filesRequest = new InitiateFileUploadsRequest() {
                 FileNames = new List<string>() {"file_1"},
                 Entity = Key,
                 ProfileVersion = null
             };
             PlayFabDataAPI.SetObjects(objectsRequest, _ => Debug.Log("SetObjectsSuccess"), error => Debug.LogError($"SetObjectsError: {error.GenerateErrorReport()}"));
             PlayFabDataAPI.InitiateFileUploads(filesRequest, OnInitiateFile, error => Debug.LogError($"InitiateFileError: {error.GenerateErrorReport()}"));
             
         }
         static void OnInitiateFile(InitiateFileUploadsResponse response) {
             Debug.Log("OnInitiateFile: Success");
             AbortFileUploadsRequest abortRequest = new AbortFileUploadsRequest() {
                 FileNames = new List<string>() {"file_1"},
                 Entity = Key,
             };
             PlayFabDataAPI.AbortFileUploads(abortRequest, _ => Debug.Log("Abort success"), _ => Debug.Log("Abort failure"));
         }

When I set the ProfileVersions of both requests to null or 0, then the error I get is "EntityProfileVersionMismatch". The function that returns this error depends on which function "reaches" the server first. When I try setting the ProfileVersions of both requests to an arbitrary number greater than zero, then the error I get is "SetObjectsError: /Object/SetObjects: The version 1 did not match the profile version of 907". (This is expected behavior but was curious what the expected version was).

entitiesdata
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Neils Shi avatar image
Neils Shi answered

When I set the ProfileVersions of both requests to null or 0, then the error I get is "EntityProfileVersionMismatch".

If you set the ProfileVersions/ExpectedProfileVersion to null or 0, and these two APIs are called separately, both APIs will be successfully called. The reason you reported the error is because you called both APIs at the same time. Since calling these two APIs will change the current version, an error will be reported when they are called at the same time(they all want to change the current version from 1 to 2). You should wait for one API to finish calling, and then call next.

I get is "SetObjectsError: /Object/SetObjects: The version 1 did not match the profile version of 907". (This is expected behavior but was curious what the expected version was).

You can set "expected version" to ensure that the object set will only be performed if the profile has not been updated by any other clients since the version you last loaded. That means if the "expected version" does not match the current version(you can get current version via GetProfile API), the object set will not execute. The same goes for another API InitiateFileUploads, if you set and doesn't match the current version of the profile, the operation will also not be performed, and you will get the "EntityProfileVersionMismatch" error.

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Bryan Matsui Pierce avatar image Bryan Matsui Pierce commented ·

Ah, got it. I assumed that if the ExpectedProfileVersion is set to null or 0, then it didn't matter what the current version was, allowing us to call both at the same time.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.