nigirigames avatar image
nigirigames asked

Testing Recipes on Editor (Unity3D)

Hi guys!

I'm really a newbie in this area, so I'm obliged to ask. Can I test any of the recipes PlayFab provides in the Editor?

I'm trying to get the Regenerating Currency one work, but I'm getting a "HTTP:400 InvalidParams -- Invalid Input Parameters" message.
I've followed the Preparation Section, and add my TitleId where needed (In PlayFabSettings.cs)

Thanks in advance.

10 |1200

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

Zac Bragg avatar image
Zac Bragg Deactivated answered

Hello Nigiri,

I just ran through the steps and noticed that the SDK download link changed. I just updated these for the regenerating currency, and will be updating the other recipes here in a moment.

Overall, the instructions work fine, and I just tested with the latest SDK.

  1. Follow the steps in the Preparation Section
  2. Make a new Unity project
  3. import the two packages (SDK & Recipe)
  4. Add your title id
  5. Run the editor
  6. Observe the console for output

Let me know if you have any issues, and make sure to provide as much details as possible (error codes, messages, stack traces etc).

10 |1200

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

brendan avatar image
brendan answered

In general, if you're following all the steps in the Preparation section, then yes, you should be able to use the sample code as-is. What API call is getting the 400 return, and what is being returned in the errorDetails parameter of the response?

10 |1200

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

developerjazzhaq avatar image
developerjazzhaq answered

Hi Zac,

I think i am using an old sdk for playfab, i have the following content of playfab.

If i try to add the referral recipe, i am getting the following error,

"The type or namespace name `ExecuteCloudScriptResult' could not be found. Are you missing a using directive or an assembly reference?"

If i am replacing my PlayFab sdk with new sdk i see that its completely different and gives me lot of errors.

Please help.


10 |1200

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

brendan avatar image brendan commented ·

The issue here is that you need to update to the latest SDK version, as it appears the one you're using does not have the API method in question. You mentioned in another thread that when you update your SDK, you're seeing errors in your build, so that's the issue we should be trying to solve. What are the errors you're seeing?

0 Likes 0 ·
Zac Bragg avatar image Zac Bragg commented ·

Yes, and I will add that I recommend starting a new project, importing the latest SDK, and then the recipe package of your choosing.

0 Likes 0 ·
developerjazzhaq avatar image
developerjazzhaq answered

On using the new PlayFabUnity sdk i am getting "internal server error". Here is my code for login. Please tell me the problem. This is running fine for old sdk but not new one.

using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System.Collections.Generic;
using PlayFab;
using PlayFab.ClientModels;

namespace PlayFab.Examples
public class PlayFabLoginUser : MonoBehaviour
public InputField UsernameN, PasswordN;
public Button LoginN, RegisterN;
public Text errorMsgN;
public AudioClip ButtonPressSound,ErrorSound,SuccessSound;
public GameObject PhotonStuff, LoginStuff, RegisterStuff,Loading,ForgotPasswordStuff;

public string nextScene = "PF_PurchaseScene";
public string previousScene = "PF_UserRegisterScene";

public string accountNotFound = "That account could not be found.";
public string accountBanned = "That account has been banned.";
public string invalidPassword = "Password is invalid (6-24 characters).";
public string invalidUsername = "Username is invalid (3-24 characters).";
public string wrongPassword = "Wrong password for that user.";

private string errorLabel = "";

private bool isPassword = true;
private bool returnedError = false;
//public GUISkin mySkin;

public static Dictionary<string,int> VirtualCurrency;
AudioSource audio=new AudioSource();

void Start(){
UsernameN.text = PlayerPrefs.GetString ("PN");
PasswordN.text = PlayerPrefs.GetString ("PS");
audio = GetComponent<AudioSource> ();
// if we are in "login" state, draw the login window on screen
void OnGUI ()
errorMsgN.text = errorLabel;
if (!isPassword) {
errorLabel = invalidPassword;
} else if (!returnedError) {
errorLabel = "";

// callback function if player login is successful
public void OnLoginResult (LoginResult result)
Loading.SetActive (true);
GetInventory ();
LoadUserData ();
LoginStuff.SetActive (false);
RegisterStuff.SetActive (false);

PlayFabGameBridge.gameState = 3;// switch to playing the game; hide this dialog
//Time.timeScale = 1.0f;// unpause...
//PlayFabData.AuthKey = result.SessionTicket;
MasterJazzBridge.MasterPlayerName= UsernameN.text;
audio.PlayOneShot (SuccessSound);
void GetInventory()
Debug.Log("Getting the player inventory...");
GetUserInventoryRequest request = new GetUserInventoryRequest();
PlayFabClientAPI.GetUserInventory(request, OnGetInventoryCallback, OnPlayFabError);

void OnGetInventoryCallback(GetUserInventoryResult result)
Debug.Log(string.Format("Inventory retrieved. You have {0} items.", result.Inventory.Count));
if (result.Inventory.Count == 0)
purchaseDummy ();
int gmBalance;
result.VirtualCurrency.TryGetValue("GC", out gmBalance);
MasterJazzBridge.MasterMoney = gmBalance;
Debug.Log(string.Format("You have {0} Gems.", gmBalance));
//Debug.Log(string.Format("You have {0} Item.", result.Inventory.ToString()));
MasterJazzBridge.MasterInventory = result.Inventory;
for (int i = 0; i < MasterJazzBridge.MasterInventory.Count; i++) {
//Saving all Inventory items
Debug.Log ("MasterJazzBridge.MasterInventory[i]" + MasterJazzBridge.MasterInventory [i].ItemId);
private void LoadUserData(string authKey = null){
GetUserDataRequest request = new GetUserDataRequest ();
PlayFabClientAPI.GetUserData (request, SetPlayerData, OnPlayFabError);
private void SetPlayerData(GetUserDataResult result)
Loading.SetActive (false);
PhotonWork.loginSucceded = true;
PhotonStuff.SetActive (true);
Debug.Log ("Player data loaded.");
if (result.Data.ContainsKey ("skinInUse"))
MasterJazzBridge.MasterSkinInUse = int.Parse (result.Data ["skinInUse"].Value);
MasterJazzBridge.MasterSkinInUse = 0;
Debug.Log ("MasterJazzBridge.MasterSkinInUse: " + MasterJazzBridge.MasterSkinInUse);
// callback function if there is an error -- display appropriate error message
void OnPlayFabError (PlayFabError error)
audio.PlayOneShot (ErrorSound);
returnedError = true;
Debug.Log ("Got an error: " + error.Error);
if (error.Error == PlayFabErrorCode.InvalidParams && error.ErrorDetails.ContainsKey ("Password")) {
errorLabel = invalidPassword;
} else if (error.Error == PlayFabErrorCode.InvalidParams && error.ErrorDetails.ContainsKey ("Username")) {
errorLabel = invalidUsername;
} else if (error.Error == PlayFabErrorCode.AccountNotFound) {
errorLabel = accountNotFound;
} else if (error.Error == PlayFabErrorCode.AccountBanned) {
errorLabel = accountBanned;
} else if (error.Error == PlayFabErrorCode.InvalidUsernameOrPassword) {
errorLabel = wrongPassword;
} else {
errorLabel = "Unknown Error.";

public void methodLoginClicked ()
audio.PlayOneShot (ButtonPressSound);
isPassword = true;
string uname = UsernameN.text;
string pass = PasswordN.text;
if (uname.Length > 0 && pass.Length > 0) {
PlayerPrefs.SetString ("PN", uname);
PlayerPrefs.SetString ("PS", pass);

returnedError = false;
LoginWithPlayFabRequest request = new LoginWithPlayFabRequest ();
request.TitleId = "1849";
request.Username = uname;
request.Password = pass;
PlayFabClientAPI.LoginWithPlayFab (request, OnLoginResult, OnPlayFabError);
} else {
isPassword = false;
public void methodForgotClicked(){
LoginStuff.SetActive (false);
ForgotPasswordStuff.SetActive (true);
public void methodRegisterClicked ()
audio.PlayOneShot (ButtonPressSound);
LoginStuff.SetActive (false);
PlayFabGameBridge.gameState = 1;
RegisterStuff.SetActive (true);
public void purchaseDummy(){
Debug.Log ("Going for dummy purchase");
PurchaseItemRequest request = new PurchaseItemRequest ();
request.VirtualCurrency = "GC";
request.Price = 0;
request.ItemId = "Dummy";
PlayFabClientAPI.PurchaseItem (request, OnPurchase, OnPlayFabError);
public static void OnPurchase (PurchaseItemResult result)
Debug.Log ("Dummy Purchase success");
MasterJazzBridge.MasterSkinInUse = 0;
PlayFabItemsController.instance.UpdateInventory ();
10 |1200

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

brendan avatar image
brendan answered

@developerjazzhaq: We're not seeing anything wrong with that usage. Can you please send a repro project showing this issue to us at

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.