Sign In Register

How can we help you today?

Start a new topic

Create downloadables from REST API

Using Unity3D.
We have defines for each level stored in XML files which we would like to put in downloadables.
That way we can change the levels and even add new ones without it being required for our players to update the game.
Right now for each new level we add, we have to first go to the downloadables section on the portal to create the shortcode and upload the xml there.

We can already update the levels using the REST API, but it would be very helpful if we could create new ones as well from within the Unity Editor.
(Now it returns: "Short code [DEF_LEVEL_2] Unknown" if we try upload a new one).

I can imagine this feature being a great addition for other types of games (like when there's a level editor for players) as well.

Is there already a way to do this?

Thanks in advance.

Hi Liam,

We are still having this issue so we are using Amazon S3 for our asset bundles for now.

1 person likes this

Hi Enrico,

There is basic support for this within the Unity Editor. If you click "GameSparks" in the top bar in the editor and then select "Rest Api" the following window will pop up.


You can then add the shortCode, your portal userName and password and selected file. Then hit POST. This file should now be in your Downloadables on the portal. You can also upload directly through our documentation page here.



1 person likes this

@Liam I implemented this code into an Asset Bundle system so I can upload them it works fine then I tried to add other people into the project and when they tried it doesn't allow them they get 403 error, looks like this only works with the owner account.

1 person likes this
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
 public class Upload
    public void UploadFile()
       System.Net.ServicePointManager.ServerCertificateValidationCallback +=
  delegate(object sender, System.Security.Cryptography.X509Certificates.X509Certificate certificate,
  System.Security.Cryptography.X509Certificates.X509Chain chain,
  System.Net.Security.SslPolicyErrors sslPolicyErrors)
  return true; // **** Always accept
       private static string HOST = "";

       private static string REST_URL = HOST + "rest/";
       string apiKey, string username, string password, string shortCode, string fileName;
       string url = REST_URL + apiKey + "/binarycontent/" + shortCode;

  String ret = null;
       FileParameter param = new FileParameter(GetBytesFromFile(fileName), Path.GetFileName(fileName));
  param.FileName = fileName;

  IDictionary<string, object> postParams = new Dictionary<string, object>();
  postParams.Add("binaryContentFile", param);

  return MultipartFormDataPost(url, postParams, username, password);


Hi Hjupter,

Apologies for the delayed response. I've tested this and it works fine for me and collaborators in the game. If you're still having an issue please raise a ticket and we'll investigate this for you.



Thank you!

So my asset bundle upload/download process is almost entirely automated now! But I ran into a single snag, uploading a downloadable with the same short code as an existing one does not replace the old one. When the downloadable ID is included in the request the file is properly replaced. Unfortunately there does not appear to be a simple automated way to get the id.

So I have a new request, can the "games/binaries/edit.html" endpoint be modified to replace downloadable with the same shortcode without need of id? This doesn't seem like it would create any issues. If not that then maybe return the downloadable id when calling the edit endpoint (it returns nothing right now so I also don't see that causing issues). But just not needing the id to replace would be ideal.

If any changes like that are off the table can someone confirm if the downloadable id can be trusted to be the same as long as it exists? If all I gotta do is scrape the id off the website after the first upload and store it on my end that's not too bad at all.

I'd like to bump this issue up...

Being able to automate the creation/update of downloadables will be a key issue for my team....

In newer version of GameSparks (v5.6.5.214 or they've changed something on their endpoints) for Unity the method setDownloadable of GameSparksRestApi.cs does not work. After hours trying to figure out what was wrong, it seems that the issue is in GameSparksEditorFormUpload.cs, Line 24: "binaryContentFile" should actually be "file", using the "binaryContentFile" will result in 403 Forbidden with no error message.

Is there an easy way to do this from the Gamespark Unity SDK?

I have a bunch of level data file I would like to upload to the "Downloadables" section but I can't figure out an easy way to do it, am I missing something?

The setDownloadable function in GameSparksRestApi.cs (Unity api) properly replaces existing downloadables of the same name. So automated creation/update works fine now.

I'll have to look closer at their cs code...

thanks for the tip!

Any news on this? I could definitely make use of uploading downloadables. If this feature is being worked on I think allowing metadata to be added to downloadables could be useful too, particularly if you could access the downloadables data via cloud code. My intention is to upload Asset Bundles with version numbers and have the client get a list of downloadables and their version numbers (or something of that nature). While this would be ideal, uploading my planned downloadables manually and keeping a metaCollection with version numbers up to date should not require an insurmountable amount of effort.

As was mentioned UploadUrlRequest could work as an alternative, would it be reliable with Asset Bundles potentially as large as ~5MB? Although I don't like the idea of not being able to see uploads in the configurator.

It seems to me that player uploaded data and downloadables could potentially benefit from being combined into a single file system. One that is viewable from the configurator, has metadata, and comes with Cloud Code APIs that can be used to query said meta data.

See my previous comment, this is exactly what I needed as well. Code is included in comment
Login to post a comment