question

ondra avatar image
ondra asked

Error calling server.GetAllSegments()

I am writing a Cloudscript handler which calls /Server/GetAllSegments API using the built-in "server" object. But unfortunately this call causes an exception which seems to happen somewhere inside PlayFab code:

Error: The best overloaded method match for 'PlayFab.LogicServer.Source.PlayFabAPI.api_request(string, string, string)' has some invalid arguments
    at HostDelegate.<anonymous> (<anonymous>)
    at Object.server_request (Script:153:41)
    at Object.server.GetAllSegments (Script:519:71)
    at handlers.abcdef (XXXXX-main.js:86:26)
    at Object.invokeFunction (Script:116:33)

Minimal example code to trigger this:

handlers.abcdef = function(args, context) {
    const segments = server.GetAllSegments();
}

Just call this Cloudscript and it should throw the above error.

CloudScript
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

·
Hernando avatar image
Hernando answered

The reason for this issue is that a necessary parameter was not provided in your GetAllSegments() request, please refer the following code to fix it:

    var request = {};
    var segments = server.GetAllSegments(request);
    return segments;

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.