question

Adrian avatar image
Adrian asked

Server/GrantCharacterToUser - request header not in the response

Server/GrantCharacterToUser

Is it possible to get this API call to return the PlayfabID that the character was created for? Currently it only returns CharacterId and since this value isn't globally unique - shouldn't it always be paired with a PlayfabID?

Once I get a response back from the API call to my server, the server doesn't know the corresponding PlayfabID of the character that was created.

Thanks in advance.

apissdks
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

·
Andy avatar image
Andy answered

It depends a bit on the SDK, but what you're after should be possible today. In Unity, the GrantCharacterToUserResult type that you get back from the call contains a Request property. This property can be cast to a GrantCharacterToUserRequest, which will then contain a PlayFabId property.

In Unreal CPP, we don't make the request object available to the response, so you instead need to use the CustomData parameter on the GrantCharacterToUser method. This data is round-tripped back to the client and is available in the CustomData property on the response object. This method should technically work in any SDK, but is slightly more complex than the first option.

4 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.

Adrian avatar image Adrian commented ·

Thanks for the additional info Andy.


I'm not using either of those engines, but I assume I'd have to use a CustomData parameter. I'm also sending the call from the server, not the client.

Can you let me know what this should look like in JSON format for the API call? I couldn't find any examples online.

https://{ {TitleId}}.playfabapi.com/Server/GrantCharacterToUser

{

"PlayFabId": "{ {PlayFabId}}",

"CharacterName": "charname",

"CharacterType": "chartype",

CustomData?

}

0 Likes 0 ·
Andy avatar image Andy ♦♦ Adrian commented ·

CustomData is actually round-tripped by the SDK. It's not part of the outgoing web request on the wire, so it doesn't work if you're not using one of our SDKs.

Which SDK are you using? I can potentially provide more guidance on the best way to do things.

0 Likes 0 ·
Adrian avatar image Adrian Andy ♦♦ commented ·

Hey, thanks for the reply. JavaScript.

0 Likes 0 ·
Show more comments

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.