bikashJ Ответов: 0

Чтение ответа после загрузки вложения с помощью web API


I am trying to read response after uploading an attachment using web API c#. Getting below error:

no mediaTypeFormatter is available to read an object of type 'String' from content with media type 'multipart/form-data.

Here is my part of code:

string filepath = "C:/Users/O42895/Desktop/DownloadAttachmen20189t.jpg";
              string filename = "DownloadAttachmen20189t.jpg";

              MultipartFormDataContent content = new MultipartFormDataContent();
              ByteArrayContent fileContent = new ByteArrayContent(System.IO.File.ReadAllBytes(filepath));
              fileContent.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment") { FileName = filename };
              content.Add(fileContent);
                
              client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("multipart/form-data"));

              response = await client.PostAsync("https:--.com/flex/upload/document/genericattachment", content);

var resBody = response.Content.ReadAsStringAsync().Result;
                  Console.WriteLine(resBody);

I am getting the response but unable to print or read. Please let me know if any one knows


Что я уже пробовал:

Перепробовал все возможные способы но не помогло

0 Ответов