question

brett avatar image
brett asked

FriendIdType.DisplayName

I'm trying to add friends from the client using AddFriendRequest, and passing in the Display Name as the 'request.TitleDisplayName', and even though I am using the correct capitalism and letters, it always tells me "User not found".

I thought to instead use a GetAccountInfo request, and pass in the TitleDisplayName with the friend ID, then use the PlayFabId in that response, but it also returns "User not found".

Friends
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

What is the Title ID you are testing, and what is the Title Display Name you're using in these calls?

8 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.

brett avatar image brett commented ·

Sorry your response was in my spam filter for some reason, so just happened to check it today :( I flagged it as not spam LoL.

In any case, the title ID is EAA5. For users, I've tried 'Pat', 'bu pc', 'Mr Salty', etc. I'll just copy the player names in my dashboard and paste them in the Unity text field.

I can add people from the dashboard, and removing them seems to work (removing by playfab Id). It just doesn't let me try adding them via TitleDisplayName.

0 Likes 0 ·
brendan avatar image brendan brett commented ·

You have turned on "Allow non-unique player display names" for the title. As stated on the Settings page, that means you cannot use Title Display Name for any lookup operations - that includes AddFriend.

0 Likes 0 ·
brett avatar image brett brendan commented ·

Ahh ok, I thought that could be the case, but wasn't sure. So what are my alternative options to look up people? For example, if a User wants to add a friend to their friends list, what identifying way can they do it, if they can't use their TitleDisplayName?

0 Likes 0 ·
Show more comments
brett avatar image brett commented ·

Ok so I created a new title: Af8, I left Allow Non-Unique Player Display Names disabled, and enabled to randomly generate 5 digits after display names.

It still tells me a User not found.

Searching for user Brett22079

0 Likes 0 ·
brett avatar image brett brett commented ·

I'm doing some testing (deleting accounts and recreating them) so that ID probably doesn't exist now... it is now Brett59629

0 Likes 0 ·
brendan avatar image brendan brett commented ·

It worked fine in a test I just did in your title, but I noticed something I'd glossed over, above. Are you literally using "TitleDisplayName" as the input parameter? The parameter you need to use is "FriendTitleDisplayName" (https://api.playfab.com/documentation/Client/method/AddFriend).

0 Likes 0 ·
Show more comments
brett avatar image
brett answered
private void OnAddFriendClicked()
    {
        if (string.IsNullOrEmpty(View.AddFriendName.text))
        {
            return;
        }
        AddFriend(FriendIdType.DisplayName, View.AddFriendName.text);
    }


    private void AddFriend(FriendIdType idType, string friendId)
    {
        Debug.Log("Adding Friend: " + friendId);


        var request = new AddFriendRequest();
        switch (idType)
        {
            case FriendIdType.PlayFabId:
                request.FriendPlayFabId = friendId;
                break;
            case FriendIdType.Username:
                request.FriendUsername = friendId;
                break;
            case FriendIdType.Email:
                request.FriendEmail = friendId;
                break;
            case FriendIdType.DisplayName:
                request.FriendTitleDisplayName = friendId;
                break;
        }


        PlayFabClientAPI.AddFriend(request, result =>
        {
            Debug.Log("added friend:" + friendId);
        }, (error) =>
        {
            switch (error.ErrorMessage)
            {
                case "User not found":
                    MessageManager.Instance.ShowMessage(PCMessageType.Error, new ErrorMessageData
                    {
                        Title = "Player Not Found",
                        Body = "Player \"" + friendId + "\" not found."
                    });
                    break;
            }


            Debug.Log("Error Addind Friend");
            Debug.Log(error.ErrorMessage);
            Debug.Log(error.ErrorDetails);
        });
    }
2 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.

brett avatar image brett commented ·

Here's the code I'm using. FriendIdType is an enum... It still responds with User not found

public enum FriendIdType { PlayFabId, Username, Email, DisplayName };
0 Likes 0 ·
brendan avatar image brendan brett commented ·

I was able to make that exact call for your player's Title Display Name, in your title, using Postman. Can you give that a try? I believe the issue is going to be a difference in the identifier(s) you're specifying in the call, so if you can either repro this in Postman and send me the parameters you're using, or put a breakpoint in to see the details of all the parameters and let me know that, that should provide us with the info we need.

0 Likes 0 ·

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.