question

Aleksey avatar image
Aleksey asked

server.AddFriend returns "InvalidParams" on PlayFabId

Hello! I`m trying to send friend requests via cloud script. But I have an error with the input parameters of currentPlayfabId. What's wrong?

handlers.SendFriendRequest = function(args){ 
    server.AddFriend({ 
      PlayFabId: currentPlayerId, 
      FriendPlayFabId: args[0] 
    }); 
      
    server.SetFriendTags({ PlayFabId:
      currentPlayerId, 
      FriendPlayFabId: args[0], 
      Tags: ["requestee"] 
    }); 
      
    server.AddFriend({ 
      PlayFabId: args[0], 
      FriendPlayFabId: currentPlayerId 
    }); 
      
    server.SetFriendTags({ 
      PlayFabId: args[0], 
      FriendPlayFabId: currentPlayerId, 
      Tags: ["requester"] 
    }); 
      
    server.SendPushNotification({ 
        Recipient: args[0],
        Subject: args[0],
        Message: args[1]
    });
    
};
{
    "EventName": "player_executed_cloudscript",
    "Source": "CloudScript",
    "FunctionName": "SendFriendRequest",
    "CloudScriptExecutionResult": {
        "FunctionName": "SendFriendRequest",
        "Revision": 269,
        "FunctionResult": null,
        "FunctionResultTooLarge": null,
        "Logs": [
            {
                "Level": "Error",
                "Message": "PlayFab API request error",
                "Data": {
                    "api": "/Server/AddFriend",
                    "request": {
                        "PlayFabId": "611A326C3B15643B"
                    },
                    "result": null,
                    "apiError": {
                        "code": 400,
                        "status": "BadRequest",
                        "retryAfterSeconds": null,
                        "error": "InvalidParams",
                        "errorCode": 1000,
                        "errorMessage": "Invalid input parameters",
                        "errorHash": null,
                        "errorDetails": null
                    }
                }
            }
        ],
        "LogsTooLarge": null,
        "ExecutionTimeSeconds": 0.0199433,
        "ProcessorTimeSeconds": 0.000656,
        "MemoryConsumedBytes": 9280,
        "APIRequestsIssued": 1,
        "HttpRequestsIssued": 0,
        "Error": {
            "Error": "CloudScriptAPIRequestError",
            "Message": "The script called a PlayFab API, which returned an error. See the Error logs for details.",
            "StackTrace": "Error\n    at Object.server_request (Script:181:24)\n    at Object.server.AddFriend (Script:501:66)\n    at handlers.SendFriendRequest (CF55A-main.js:78:12)\n    at Object.invokeFunction (Script:117:33)"
        }
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

·
JayZuo avatar image
JayZuo answered

According to the Error Data, I'm afraid the problem is not the "currentPlayfabId", but "args[0]". In /Server/AddFriend request, we can see there is only PlayFabId, but no FriendPlayFabId, that why you got a 400 BadRequest.

"api": "/Server/AddFriend",                    

"request": {                        

    "PlayFabId": "611A326C3B15643B"                    

},

I'd suggest you recheck your client API call and make sure you've specified correct FunctionParameter.

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.

Aleksey avatar image Aleksey commented ·

My bad. Thanks for help!

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.