I’m trying to upload a file, but I keep getting 400 bad request, code below:
var options = new {
access = “PUBLIC_INDEXABLE”,
ttl = “P3M”,
overwrite = false,
duplicateValidationStrategy = “NONE”,
duplicateValidationScope = “ENTIRE_PORTAL”
};
var url = “/filemanager/api/v3/files/upload”;
var properties = JsonConvert.SerializeObject(options);
var fileInfo = new FileInfo(“C:\\Users\\Pedro\\Desktop\\beagle.jpg”);
using var content = new ByteArrayContent(File.ReadAllBytes(fileInfo.FullName));
var postContent = new MultipartFormDataContent();
postContent.Add(content, “file”, “beagle.jpg”);
postContent.Add(new StringContent(properties), “options”);
postContent.Headers.ContentType = new MediaTypeHeaderValue(“multipart/form-data”);
var result = _httpClient.PostAsync(url, postContent).Result;