question

Bob Sabiston avatar image
Bob Sabiston asked

Error uploading a server zip and creating a build from C#?

We've been getting sporadic fails when uploading our builds using the Powershell API, so I am trying to implement the process in C# to see if it works any better. Is there documentation anywhere for doing that?

I think it is almost working - I am getting the upload URL and it seems to upload my build OK. The Create Build step is failing, however. It's returning this:


Error MultiplayerServerBadRequest PlayFab.PlayFabErrorCode
+ ErrorDetails Count = 1 System.Collections.Generic.Dictionary<string, string[]>
ErrorMessage "MultiplayerServerBadRequest - ValidationError - There were errors during request validation." string
HttpCode 400 int
HttpStatus "BadRequest" string
RequestId "Failed to Enumerate RequestId. Exception message: Enumeration has not started. Call MoveNext." string

Here is how I'm trying to create the build:

 protected static void CreateBuild(string fileName, string Token, int port)
        {
            List<PlayFab.MultiplayerModels.Port> ports = new List<PlayFab.MultiplayerModels.Port>();

            PlayFab.MultiplayerModels.Port port = new PlayFab.MultiplayerModels.Port();
            port.Name = "game_port";
            port.Num = port;
            port.Protocol = PlayFab.MultiplayerModels.ProtocolType.UDP;

            ports.Add(port);

            List<PlayFab.MultiplayerModels.AssetReferenceParams> assets = new List<PlayFab.MultiplayerModels.AssetReferenceParams>();

            PlayFab.MultiplayerModels.AssetReferenceParams assetReferenceParams = new PlayFab.MultiplayerModels.AssetReferenceParams();
            assetReferenceParams.FileName = fileName;
            assetReferenceParams.MountPath = "C://Assets";

            assets.Add(assetReferenceParams);

            List<PlayFab.MultiplayerModels.BuildRegionParams> buildRegionParams = new List<PlayFab.MultiplayerModels.BuildRegionParams>();

            PlayFab.MultiplayerModels.BuildRegionParams buildRegionParam = new PlayFab.MultiplayerModels.BuildRegionParams();
            buildRegionParam.Region = "EastUS";
            buildRegionParam.MaxServers = 1; 
            buildRegionParam.StandbyServers = 0;
             
            buildRegionParams.Add(buildRegionParam);

            string buildName = System.IO.Path.GetFileNameWithoutExtension(fileName);

            var createBuildTask = PlayFab.PlayFabMultiplayerAPI.CreateBuildWithManagedContainerAsync(new PlayFab.MultiplayerModels.CreateBuildWithManagedContainerRequest()
            //PlayFab.PlayFabMultiplayerAPI.CreateBuildWithManagedContainer(new PlayFab.MultiplayerModels.CreateBuildWithManagedContainerRequest()
            {
                //AuthenticationContext = new PlayFab.PlayFabAuthenticationContext() { EntityToken = Token },
                BuildName = buildName,
                ContainerFlavor = PlayFab.MultiplayerModels.ContainerFlavor.ManagedWindowsServerCore,
                GameAssetReferences = assets,
                MultiplayerServerCountPerVm = 1,  
                Ports = ports,
                RegionConfigurations = buildRegionParams,
                StartMultiplayerServerCommand = "C:\\Assets\\Server.exe",
                VmSize = PlayFab.MultiplayerModels.AzureVmSize.Standard_D4as_v4

            });

            createBuildTask.Wait();

            if (createBuildTask.Result.Result != null)
            {
                Console.WriteLine("Success?" + createBuildTask);
            }
            else
            {
                Console.WriteLine("createBuildTask Error: " + createBuildTask.Result.Error.ErrorMessage);
            }
        }
10 |1200

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

Sarah Zhang avatar image
Sarah Zhang answered

Since the 400 error should contain the extract Error Code, Error Message, and Error Details that will help to find the cause of the error. Could you please print the content of the Error Details dictionary, and post the complete error response? Here is an example of the full error response.

{
    "code": 400,
    "status": "BadRequest",
    "retryAfterSeconds": null,
    "error": "InvalidRequest",
    "errorCode": 1071,
    "errorMessage": "Invalid JSON in request",
    "errorHash": "9101c103f48e5d142e794a6f7629ee39",
    "errorDetails": {
        "ValidationError": [
            "Could not convert string to boolean: Boolean. Path 'AreAssetsReadonly', line 2, position 32."
        ]
    }
}
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.

Bob Sabiston avatar image Bob Sabiston commented ·

Thanks - it was an incorrect path error! I have

"C://Assets"

instead of

"C:\\Assets"
1 Like 1 ·
Dimitris-Ilias Gkanatsios avatar image
Dimitris-Ilias Gkanatsios answered

hey @Bob Sabiston, any chance you can share the error message you got?

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.