question

katanasimulations avatar image
katanasimulations asked

CreateRole returns "/Group/CreateRole: Generic/unknown HTTP error"

I've been banging my head against a problem when creating roles for a newly created group.

A player creates a group and in OnCreateGroup I call the following to set up additional roles within this newly created group:

var requeststudent = new CreateGroupRoleRequest { Group = result.Group, RoleId = "student", RoleName = "Student" };
        PlayFabGroupsAPI.CreateRole(requeststudent, OnCreateRole, OnSharedError);

I get the group for the CreateGroupRoleRequest via the CreateGroupResponse (result.Group in this code snippet above).

I always get a Generic/unknown HTTP error, HTTP code 400, HTTP status BadRequest.

Am I doing something wrong when creating the role? My assumption is that the logged in player is admin of the newly created group, and thus, is allowed to set up new roles for this group. Is this something I should do via CloudScript instead? If so, what would a code example look like?

Thanks heaps!

-Sebastian

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

·
Hernando avatar image
Hernando answered

I can't reproduce your issue, but I guess the variable "group" in the code you posted is not correctly assigned.

Can you post the complete error response? A 400 error will always contain an error, errorMessage, and errorDetails that will help to solve the question of why the error occurred.

2 comments
10 |1200

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

katanasimulations avatar image katanasimulations commented ·

It seems the problem was that I was creating one role after another without waiting for the first role to be successfully created. The behavior was inconsistent, sometimes 1 out of 3 roles were created, sometimes not. Error messages were the following:

ErrorReport - /Group/CreateRole: Generic/unknown HTTP error

ErrorDetails - Null

HTTP Code - 400

HTTPStatus - BadRequest

ErrorMessage - Generic/unknown HTTP error

I'll rewrite this now and post an update if I can solve it. Thanks Hernando for looking into it though - I appreciate it.

0 Likes 0 ·
katanasimulations avatar image katanasimulations commented ·

It was indeed the problem that I was calling CreateRole too often without waiting for one role to be successfully created. Works like a charm now. Thanks again.

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.