Hello everyone,
I was trying to update my API policy, but I get this error.
0 is not allowed as a policy version. Make sure to merge PolicyVersion and Statements returned by GetPolicy with this request.
I was able to update the policy yesterday, now it gives me that error. This is the code I use:
static void Main(string[] args) { // ... Adjusting static settings here. Title ID and Secret Key WritePolicy(); GetPolicy(); } static void WritePolicy() { Console.WriteLine("Writing a New API Policy...\n"); UpdatePolicyRequest updatePolicy = new UpdatePolicyRequest() { OverwritePolicy = true, PolicyName = "ApiPolicy", Statements = new List<PermissionStatement>() { new PermissionStatement() { Action = "*", ApiConditions = new ApiCondition() { HasSignatureOrEncryption = Conditionals.False }, Comment = "test", Resource = "pfrn:api--/Client/LoginWithPlayFab", Effect = EffectType.Allow, Principal = "*" }, } }; Task<PlayFabResult<UpdatePolicyResponse>> policyResult = PlayFabAdminAPI.UpdatePolicyAsync(updatePolicy); while (!policyResult.IsCompleted) { Thread.Sleep(1000); } //Console.WriteLine(policyResult.Result.Error.ErrorMessage); } static void GetPolicy() { Console.WriteLine("Getting API Policy...\n"); GetPolicyRequest getPolicy = new GetPolicyRequest() { PolicyName = "ApiPolicy" }; Task<PlayFabResult<GetPolicyResponse>> policyResult = PlayFabAdminAPI.GetPolicyAsync(getPolicy); while (!policyResult.IsCompleted) { Thread.Sleep(1000); } foreach (var item in policyResult.Result.Result.Statements) { Console.WriteLine("Action: " + item.Action); Console.WriteLine("Comment: " + item.Comment); if (item.ApiConditions != null) { Console.WriteLine("ApiCondition.HashSignatureOrEncryption: " + item.ApiConditions.HasSignatureOrEncryption); } Console.WriteLine("Effect: " + item.Effect); Console.WriteLine("Principal: " + item.Principal); Console.WriteLine("Resource: " + item.Resource); Console.WriteLine(""); } Console.ReadKey(); }
I'm trying to change the API policy of my test game, which is in this account. Title ID: AFE9A