Is it possible to generate/upload a new version of an asset using the WebClient SDK in Content Hub? I am aware that this can be done through the Portal, but I need to perform this task programmatically.

  • From what I have seen so far, there is no method in SDK to create a new version of existing asset. SDK provides basic CRUD operations, but the changes apply on the same version. worth comparing the system properties of two versions of the same assets from the portal and checking whether submitting those properties via SDK creates a separate version though..
    – Shiham
    Feb 13 at 6:03

3 Answers 3


Ideally, it would be best if you used that upload OOTB functionality from Content Hub, but for your specific need, you could refer to a code snippet that could help you rebuild and Upload a new version of the same Asset.

Note: The code below is not the exact solution you need to use this as a sudo code for reference and create a new code for specific requirements. Hope this will help.

using Stylelabs.M.Sdk.WebClient;
using Stylelabs.M.Sdk.WebClient.Authentication;
using Stylelabs.M.Sdk.WebClient.Models.Upload;
using System;
using System.Threading.Tasks;

namespace WebSDK
    public class Test
        static async Task Main(string[] args)
            Uri endpoint = new Uri("https://your.m.endpoint.com");

            OAuthPasswordGrant oauth = new OAuthPasswordGrant
                ClientId = "client_id",
                ClientSecret = "client_secret",
                UserName = "username",
                Password = "password"

            IWebMClient mClient = MClientFactory.CreateMClient(endpoint, oauth);

            var uploadSource = new LocalUploadSource("C:\\my-image.jpg", "my-image.jpg");

            /*http://tinyurl.com/353dw72w this is the link how upload request works.
              http://tinyurl.com/534azds4 this is the link to check how upload api works.
            var request = new UploadRequest(uploadSource, "AssetUploadConfiguration", "NewAlternativeFile"); 

            var response = await mClient.Uploads.UploadAsync(request).ConfigureAwait(false);

            var responseId = await mClient.LinkHelper.IdFromEntityAsync(response.Headers.Location).ConfigureAwait(false);
  • Thank you, Nikhil, for your assistance. I was continuously researching the issue, and your response was very helpful. Although it was 80% accurate, I made a slight code adjustment to resolve a validation error. Now, it's working perfectly. I've also shared my solution.
    – Gautam
    Feb 16 at 7:17
  • @Gautam As I mentioned in the answer you might need to change a few things in the code which will accommodate your needs that seems to work could you please maybe mark this as an answer and add your update in the question Feb 17 at 7:33

Finally, I found the 100% solution for that. Sharing it here to benefit the community:

IWebMClient _mclient = MClientFactory.CreateMClient(endpoint, oauth);
var uploadSource = new LocalUploadSource("C:\SomeFolder\New.png");
Dictionary<string, object> action = new Dictionary<string, object>();
action.Add("AssetId", 109956);
var request = new UploadRequest(uploadSource, "AssetUploadConfiguration", "NewAlternativeFile");
request.ActionParameters = action;
var response = await _mclient.Uploads.UploadAsync(request).ConfigureAwait(false);

In the upload request, there's a third parameter called "supported action." Depending on your requirement:

  • To create a completely new asset, use "NewAsset.".
  • To create a new version, use "NewMainFile.".
  • To replace the image, use "NewAlternativeFile.".

Some additional information regarding this topic that might help others.


In Content Hub in Entities you can search for M.UploadConfiguration you can modify your configuration that is needed. Settings you can change are:

  • uploadFileProvider: local
  • uploadLocation: local
  • entityConfiguration:
  • lifeCycle: Created
  • contentDisposition:
  • relations:
  • properties:
  • repository:
  • mediamatrix:
  • disableProcessing: false
  • disableDistribution: false
  • disableDuplicate: false
  • maxFileSizeInBytes: 50000000000
  • disallowedExtensions:
    • exe
    • dll
  • allowed_extensions:
  • upload_url_lifetime_in_minutes: 10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.