question

giacomopmariani avatar image
giacomopmariani asked

Friend Add Request (Display Name) - Possible string issue?

When I try searching and I type the name of the friend it gives back an error response like:

{
 "code": 400,
 "status": "BadRequest",
 "error": "AccountNotFound",
 "errorCode": 1001,
 "errorMessage": "User not found",
 "CallBackTimeMS": 403
}

I tried it both on unity but also on the web Sample Request.

https://api.playfab.com/documentation/Client/method/AddFriend.

On the other hand, if I go to friend page, COPY AND PASTE the name of the friend it works as expected.

I tried also printing the name of the friend "iPad58"from the Cloud Script and I get this:

iPad58\M-b\M^@\M^Z\M-C\M^D\M-C\M-#

Everything works when I with scripting too (both with userId and DisplayName). The issue raises just when I send a AddFriendRequest and type the Display Name.

Player DataFriends
9 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.

v-humcin avatar image v-humcin ♦ commented ·

Hello, can you clarify what you mean you say the issue only happens when you type the display name? In unity is this occurring at runtime by typing into a InputField or something similar and then passing that value into the request?

0 Likes 0 ·
giacomopmariani avatar image giacomopmariani v-humcin ♦ commented ·

It happens if I type the dusplay name on an inputfield on the editor at runtime or on iOS build. The request is then created from the inputfield.

But it happens also if I type it in the sample request here:
https://api.playfab.com/documentation/Client/method/AddFriend.

0 Likes 0 ·
v-humcin avatar image v-humcin ♦ giacomopmariani commented ·

Does this happen with all players or just "iPad58"? Can you post the code involving creating the request from the input field and also try printing out the "FriendTitleDisplayName" value of the request after it is initialized, so we can see if it is being created as expected?

0 Likes 0 ·
Show more comments
Seth Du avatar image Seth Du ♦ commented ·

Have you enabled Allow non-unique player display names at [Game Manager] -> [Settings] -> [General] ? it sounds like you have enabled it and once enabled, it cannot be disabled any more. You may find that you cannot directly use the DisplayName shown on the Game Manager to add friends after that.

0 Likes 0 ·
giacomopmariani avatar image giacomopmariani Seth Du ♦ commented ·

Just checked.
Allow non-unique player display names is disabled.

>Did anything change about the "iPad58" account in the time before the api call started working for that account?

No changes that I know of from the code. And no one re assigned it.
For the next session of QA I'm setting a Regex to remove all non AlphaNumeric data, but I see this should be already done from playfab, so I do not expect much change.

>For further testing can you provide the title id for this game?
Yes, but I would please send this on private. Is there any way to do that?

0 Likes 0 ·
v-humcin avatar image v-humcin ♦ giacomopmariani commented ·

You can post the title id on here, it is information that is visible to all players of your game, so you do not need to worry about keeping it secret.

0 Likes 0 ·
Show more comments
brendan avatar image
brendan answered

If you call Server/GetUserAccountInfo on that player, you'll see that the Display Name has a space at the end of it. So it's actually "iPad58 ", it's just that the Game Manager strips the trailing space. We'll open a bug on the Game Manager to make sure this is corrected.

1 comment
10 |1200

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

giacomopmariani avatar image giacomopmariani commented ·

I'll also add a method to Trim the names when I set them, just to make sure it won't happen on my side too.

0 Likes 0 ·
Ethan K. G avatar image
Ethan K. G answered

Is this issue fixed?

I get same error here: "/Client/AddFriend: User not found". Only has this issue with DisplayName.

This is with Unity SDK. Any hint or update is appreciated.

    public static void AddFriend(string input, AddFriendMethod method, UnityAction<bool> callback = null)
    {
        var request = new AddFriendRequest();
        switch (method)
        {
            case AddFriendMethod.DisplayName:
                request.FriendTitleDisplayName = input; break;
            case AddFriendMethod.Email:
                request.FriendEmail = input; break;
            case AddFriendMethod.Username:
                request.FriendUsername = input; break;
            case AddFriendMethod.PlayFabID:
                request.FriendPlayFabId = input; break;
        }


        //DialogCanvasController.RequestLoadingPrompt(PlayFabAPIMethods.AddFriend);
        PlayFabClientAPI.AddFriend(request, result =>
        {
            if (callback != null)
                callback(result.Created);


            PFBridge.RaiseCallbackSuccess(string.Empty, PlayFabAPIMethods.AddFriend, MessageDisplayStyle.none);
        }, PFBridge.PlayFabErrorCallback);
    }
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.