question

duartedd avatar image
duartedd asked

UserisNotValid Update Character Read Only

Hello

I keep getting this error when I try to update the character

... I am running through a loop...its strange all of them report errors with the below;

2021-12-11T20:45:18.702 [Information] characterdata 584C3160B7ED1A7A count: 3
2021-12-11T20:45:18.709 [Information] characterdata 584C3160B7ED1A7A character id: 6277C93C83CB8F61 health id: 5
2021-12-11T20:45:18.876 [Information] characterdata 584C3160B7ED1A7A result: {"Result":null,"CustomData":null,"Error":{"HttpCode":400,"HttpStatus":"BadRequest","Error":1030,"ErrorMessage":"UserisNotValid","ErrorDetails":null,"RequestId":"Failed to Enumerate RequestId. Exception message: Enumeration has not started. Call MoveNext.","RetryAfterSeconds":null}}  

the foreach loop in the functions:

 foreach( var keeper in playerKeepers)
  { 
           log.LogInformation($"characterdata {context.CurrentPlayerId} character id: {keeper["keeperDetails"]["CharacterId"]} health id: {keeper["keeperData"]["Health"]}");
 
    var characterData = keeper["keeperData"];

         
var data = new Dictionary<string,string>() 
{
  { "CharacterData", PlayFabSimpleJson.SerializeObject(characterData) }
};
    UpdateCharacterDataRequest updateDataRequest = new UpdateCharacterDataRequest {
        PlayFabId = context.CurrentPlayerId,
        CharacterId = keeper["keeperDetails"]["CharacterId"],
        Data = data,
        Permission = UserDataPermission.Public
    };
 var result =   await   serverApi.UpdateCharacterReadOnlyDataAsync(updateDataRequest); 
 
   log.LogInformation($"characterdata {context.CurrentPlayerId} result: {PlayFabSimpleJson.SerializeObject(result)}");
   log.LogInformation($"characterdata {context.CurrentPlayerId} result: {result.Result.DataVersion}");
 
   log.LogInformation($"characterdata {context.CurrentPlayerId} error: {result.Error.ErrorMessage}");
  }


what is the userisnotvalid message indicating here?

called from unity - to the azure function - character read only permission is public - is it something to do with the currentplayerid and entity id deal ?

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

·
duartedd avatar image
duartedd answered

Fixed: changed titleplayerid to masterplayerid

     return new FunctionContext<TFunctionArgument>()
                {
                    ApiSettings = settings,
                    CallerEntityProfile = contextInternal.CallerEntityProfile,
                    FunctionArgument = contextInternal.FunctionArgument,
                    AuthenticationContext = authContext,
                    CurrentPlayerId = contextInternal.CallerEntityProfile.Lineage.TitlePlayerAccountId
                };

to

     return new FunctionContext<TFunctionArgument>()
                {
                    ApiSettings = settings,
                    CallerEntityProfile = contextInternal.CallerEntityProfile,
                    FunctionArgument = contextInternal.FunctionArgument,
                    AuthenticationContext = authContext,
                    CurrentPlayerId = contextInternal.CallerEntityProfile.Lineage.MasterPlayerAccountId
                };

10 |1200

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

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.