I have…
- [x] Read the following guideline: https://docs.squidex.io/01-getting-started/installation/troubleshooting-and-support. I understand that my support request might get deleted if I do not follow the guideline.
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(
"http://wallpapers.net/web/wallpapers/beautiful-water-house-nature/1080x608.jpg");
byte[] content = await downloadResponse.Content.ReadAsByteArrayAsync();
var formData = new MultipartFormDataContent();
formData.Add(new ByteArrayContent(content, 0, content.Length));
formData.Add(new StringContent(
JsonSerializer.Serialize(new
{
mimeType = "image/jpg"
}),
Encoding.UTF8,
"application/json"));
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,
formData);
response.EnsureSuccessStatusCode();
}
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
Environment
App Name:
- [x] Self hosted with docker
- [ ] Self hosted with IIS
- [ ] Self hosted with other version
- [ ] Cloud version
Version: [VERSION]
Browser:
- [x] Chrome (desktop)
- [ ] Chrome (Android)
- [ ] Chrome (iOS)
- [ ] Firefox
- [ ] Safari (desktop)
- [ ] Safari (iOS)
- [ ] IE
- [ ] Edge
Others: