question

ryan-2 avatar image
ryan-2 asked

How do I access PlayFabServerAPI?

public void ServerGetTitleData() {
    PlayFabServerAPI.GetTitleData( new GetTitleDataRequest(),
        result => {
            if (result.Data == null || !result.Data.ContainsKey("MonsterName")) Debug.Log("No MonsterName");
            else Debug.Log("MonsterName: " + result.Data["MonsterName"]);
        },
        error => {
            Debug.Log("Got error getting titleData:");
            Debug.Log(error.GenerateErrorReport());
        });
}

Testing few things here and there. I need this example code to work, sadly I'm getting exception with PlayFabServerAPI and it doesn't tell me which namespace to use, but only to create new one(property, field, class, etc).

What should I do to use PlayFabServerAPI?

Title Data
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

·
Seth Du avatar image
Seth Du answered

I assume you are using Unity Engine to develop, and we suggest you using our Unity Extension to enable the Server API. Please refer to Andy’s answer in this thread: https://community.playfab.com/questions/25088/if-enable-playfabserver-api.html

Please also note that it will be fine if you enable server API only for testing purposes, however, we do not recommend to enable server API in the client since it requires secret key, which should not be exposed to any players. Another solution to test server API conveniently is via RESTful testing tool like Postman, please find the JSON collection on: https://docs.microsoft.com/en-us/gaming/playfab/sdks/postman/.

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.