question

Alberto Gomez avatar image
Alberto Gomez asked

SubtractUserVirtualCurrency returns Invalid input parameters

I'm calling SubtractUserVirtualCurrency with what I think are the correct type of parameteres, but I get a playfab error that says "Invalid input parameters".

Here is the code:

public void ChangeTreasure()
{
if (GlobalMethods.IsInternetReachable() &&v PlayFabClientAPI.IsClientLoggedIn())
{
SubtractUserVirtualCurrencyRequest request = new SubtractUserVirtualCurrencyRequest();
request.Amount = (int)regenerateTreasure;
request.VirtualCurrency = "GM";
PlayFabClientAPI.SubtractUserVirtualCurrency(request, OnSubstractedVirtualCurrency, OnSubstractionFailed);
}
}

PS: I have the Allow Client to Subtract Virtual Currency option enabled

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

There should be an errorDetails returned with any error message from our service. Can you paste the full details for the error 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.

Alberto Gomez avatar image
Alberto Gomez answered

Hi brendanv, I already tried doing that but there are no details.

This is my code to get the errors:
private void OnSubstractionFailed(PlayFabError error)
{
Debug.Log("Error: " + error.ErrorMessage + " || " + error.ErrorDetails);
}

and this is the line that it prints:

"Error: Invalid input parameters ||"

So I'm not able to guess what I'm doing wrong...

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

Wait - as a guess, are you passing in a negative number? That would cause an invalid parameters response, as the function is designed to subtract the input from the balance. The add function also returns an error if a negative number is passed in, for the same reason.

10 |1200

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

Alberto Gomez avatar image
Alberto Gomez answered

And that was exactly the problem. Thanks brendan!!
As a suggestion, could you add to the errorDetails that the amount shouldn't be negative or zero?

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

Yes, we'll get that added to the docs. Thanks!

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.