question

Brent Batas (Lisk) avatar image
Brent Batas (Lisk) asked

Bad request when uploading server 2.0 asset

I'm working on updating my developer tools for servers 2.0.

I'm having trouble having my tool upload a server build. First, I call

GetAssetUploadUrlAsync() to get a URL to post my build to. Then, I run a PUT request to upload my build.

Specifically, I'm currently using this code to do the PUT request. I already use this exact code to successfully upload builds for legacy matchmaking with my live title, from the URL fetched via

GetServerBuildUploadUrl(), so I am fairly confident that the PUT code should be okay.

static bool PutFile(string putURL, byte[] payload, Action onSuccess)
        {
            var request = (HttpWebRequest)WebRequest.Create(putURL);
            request.Method = "PUT";
            request.ContentType = "application/x-zip-compressed";

            if (payload != null)
            {
                Stream dataStream = request.GetRequestStream();
                dataStream.Write(payload, 0, payload.Length);
                dataStream.Close();
            }
            else
            {
                Dev.LogWarning(string.Format("ERROR: Byte arrry was empty or null"));
                return false;
            }

            Dev.Log("Starting HTTP PUT...");
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();

            if (response.StatusCode == HttpStatusCode.OK)
            {
                Dev.Log("...HTTP PUT Successful");
                if (onSuccess != null)
                    onSuccess();
                return true;
            }
            else
            {
                Dev.LogWarning(string.Format("ERROR: [{0}] -- {1}", response.StatusCode, response.StatusDescription));
                return false;
            }
        }

After running my PutFile code on the URL retrieved from GetAssetUploadUrlAsync, the console loads for a while (which suggests the bytes reach the server), but I get a

The remote server returned an error: (400) Bad Request

in response.

I'm not sure how to debug it further. I've tried waiting 15 minutes and running the request again, but it still fails with the same response.

I'm suspecting maybe I need to adjust the ContentType in my HttpRequest, but I'm not sure what else to put it, since I'm uploading a zip file (the same type of zip file as I'm uploading for my legacy server).

Custom Game Servers
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

·
Sarah Zhang avatar image
Sarah Zhang answered

Please ensure the following items included in Header: x-ms-blob-content-type: application/zip

x-ms-blob-type: BlockBlob. We have tested this, and it works. Uploading assets use Azure Blob storage.

You can also upload assets when you create a build, please check Quickstart for multiplayer servers (API/PowerShell) and Quickstart for multiplayer servers (Game Manager) for more.

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.

Brent Batas (Lisk) avatar image Brent Batas (Lisk) commented ·

Hi Sarah,

Thank you for the reply. I was able to get further with the Headers you suggested.

However, now I get a "Created" error response now.

https://i.imgur.com/bRsgnc3.png

Edit: never mind, it looks like Created is actually a successful call; I was expecting it to return with OK status since that was how it worked with the legacy one. You can consider this ticket resolved.

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.