C
C#3w ago
Rezi

upload csv file using httpclient problem

public async Task<Result<string>> UploadCsvFileAsync(byte[] csvData, string fileName, CancellationToken cancellationToken = default) { try { var client = _httpClientFactory.CreateClient(); using var content = new MultipartFormDataContent(); var fileContent = new ByteArrayContent(csvData); fileContent.Headers.ContentType = MediaTypeHeaderValue.Parse("text/csv"); content.Add(fileContent, "file", fileName); any idea why this is not working? returning me Unsupported or unrecognized file type. even thou, if i try it via swagger/postman on the url it actually works. it expects iformfile, binary format file string($binary)
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?