question

brendan avatar image
brendan asked

Server API Call gives Invalid input parameters

naltradamus
started a topic on Fri, 05 June 2015 at 12:53 AM

Can you guys tell me what i am doing wrong here:

private void SavePlayerState()
        {
        Debug.Log ("Saving game.2");
            // we need to save
                // first save as a player property (poor man's save game)
                Debug.Log ("Saving player data...");
                UpdateUserDataRequest request = new UpdateUserDataRequest ();
                request.PlayFabId = PlayFabClientAPI.AuthKey;
                request.Data = new Dictionary<string, string> ();
                request.Data.Add ("TotalXP", PlayFabGameBridge.totalXP.ToString ());
                request.Permission = UserDataPermission.Public;
                PlayFabServerAPI.UpdateUserData (request, PlayerDataSaved, OnPlayFabError);

                // also save score as a stat for the leaderboard use...
                Dictionary<string,int> stats = new Dictionary<string,int> ();
                stats.Add("XP", PlayFabGameBridge.totalXP);
                storeStats(stats);

            totalXPOld = PlayFabGameBridge.totalXP;
        }

i want to make it so that the client cant cheat so I want the server to post calls. I understand the documents you guys currently have up so far, im having a hard time making wrappers for unity to understand.

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

·
brendan avatar image
brendan answered

Best Answer
johntube said on Sat, 06 June 2015 at 7:58 AM

Hi naltradamus,

The following line is wrong as you're using a session ticket (aka authentication/authorization key/token/secret) as Id !

                request.PlayFabId = PlayFabClientAPI.AuthKey;

Instead you should save the PlayFabId of the currently logged in play somewhere when logging in or registering and retrieve it anytime you want :

private void OnLoginSuccess(LoginResult result){
     // you should avoid static...but hey I know it's Unity
     PlayFabGameBridge.PlayFabId = result.PlayFabId;
}

then change that line with

                request.PlayFabId = PlayFabGameBridge.PlayFabId;

I hope this helps.


1 Comment
johntube said on Sat, 06 June 2015 at 7:58 AM

Hi naltradamus,

The following line is wrong as you're using a session ticket (aka authentication/authorization key/token/secret) as Id !

                request.PlayFabId = PlayFabClientAPI.AuthKey;

Instead you should save the PlayFabId of the currently logged in play somewhere when logging in or registering and retrieve it anytime you want :

private void OnLoginSuccess(LoginResult result){
     // you should avoid static...but hey I know it's Unity
     PlayFabGameBridge.PlayFabId = result.PlayFabId;
}

then change that line with

                request.PlayFabId = PlayFabGameBridge.PlayFabId;

I hope this helps.

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.