C# post request to assets

I have…

I’m submitting a…

  • [ ] Regression (a behavior that stopped working in a new release)
  • [ ] Bug report
  • [ ] Performance issue
  • [x] Documentation issue or request

Current behavior

Hello, sorry for another ticket.
I am playing with squidex and it seems really great.
Api works very nicely but I am unable to understand how should look post request to assets in c#.
While I found some examples in typescript here on forum I dont know how to replicate in c# maybe because i have very limited experience.

static async void PostRequestMedia(HttpClient client, string Bearertoken)

            HttpClient downloadClient = new HttpClient();
            HttpResponseMessage downloadResponse = await downloadClient.GetAsync(
            byte[] content = await downloadResponse.Content.ReadAsByteArrayAsync();
            var formData = new MultipartFormDataContent();
            formData.Add(new ByteArrayContent(content, 0, content.Length));
            formData.Add(new StringContent(
                    mimeType = "image/jpg"

            client.DefaultRequestHeaders.Authorization =
    new AuthenticationHeaderValue("Bearer", Bearertoken);

            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("multipart/form-data"));
            string param = "?Duplicate=true";
            HttpResponseMessage response = await client.PostAsync(
                "api/apps/kviiik/assets" + param,


This is what i was able to build and here I am basically stack. Still getting 400 bad request. What I am doing is basically that I am downloading image from url and uploading it to squidex assets. Can I get please help on this?

Expected behavior

Minimal reproduction of the problem


App Name:

  • [x] Self hosted with docker
  • [ ] Self hosted with IIS
  • [ ] Self hosted with other version
  • [ ] Cloud version

Version: [VERSION]


  • [x] Chrome (desktop)
  • [ ] Chrome (Android)
  • [ ] Chrome (iOS)
  • [ ] Firefox
  • [ ] Safari (desktop)
  • [ ] Safari (iOS)
  • [ ] IE
  • [ ] Edge


I would just use the SDK: https://www.nuget.org/packages/Squidex.ClientLibrary

Or search for PostAssetAsync in this file (second result):

yeah thank you great resources :slight_smile:

1 Like