question

Ivan Kozka avatar image
Ivan Kozka asked

Create Queue and rules from code

Hello everyone I'm trying to create a queue and rules for the queue from the code, but something goes wrong what is the reason? and why I get such an error "{\"code\":401,\"status\":\"Unauthorized\",\"error\":\"NotAuthorized\",\"errorCode\":1089,\"errorMessage\":\"Only title entities can call this API.\"}"

   private string CreateRule()
        {
            SetMatchmakingQueueRequest q = new SetMatchmakingQueueRequest
            {
                MatchmakingQueue = new MatchmakingQueueConfig
                {
                    Name = "PVP",
                    MinMatchSize = 2,
                    MaxMatchSize = 2,
                    MaxTicketSize = 1,
                    DifferenceRules = new List<DifferenceRule>
                      {
                          new DifferenceRule
                          {
                              Name = "trophies",
                              Attribute= new QueueRuleAttribute{Source = AttributeSource.User,Path = "Trophies"},
                              Weight=1,
                              Difference = 25
                          }
                      }
                }
            };
            return JsonConvert.SerializeObject(q);
        }


 public async Task ConfigureQueue(string entityToken)
        {
            string url = "https://7DCFA.playfabapi.com/Match/SetMatchmakingQueue";
            string json = CreateRule();
            StringContent content = new StringContent(json, Encoding.UTF8, "application/json");
            HttpClient client = new HttpClient();
            client.DefaultRequestHeaders.Add("X-EntityToken", entityToken);
            string s = await (await client.PostAsync(url, content)).Content.ReadAsStringAsync();


        }


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

·
Gosen Gao avatar image
Gosen Gao answered

As the error message mentions, this API required a title level EntityToken, you can use API GetEntityToken to get a title level EntityToken.

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.