var request = new HttpRequestMessage(HttpMethod.Get, new Uri("http://someurl"));
request.Headers.Add("Accept","multipart/related;type=application/octet-stream");
above code throws below exception
System.FormatException HResult=0x80131537 Message=The format of value 'multipart/related;type=application/octet-stream' is invalid. Source=System.Net.Http StackTrace: at System.Net.Http.Headers.HttpHeaderParser.ParseValue(String value, Object storeValue, Int32& index) at System.Net.Http.Headers.HttpHeaders.ParseAndAddValue(String name, HeaderStoreItemInfo info, String value) at System.Net.Http.Headers.HttpHeaders.Add(String name, String value) at deleteit.Program.Main(String[] args) in c:\users\310227436\source\repos\deleteit\deleteit\Program.cs:line 14
My requirement is I must have to "multipart/related;type=application/octet-stream" as Accept header, as service needs that.
Please help.
HttpClient
mostly uses strongly typed headers or tries to validate the input.
Try using:
request.Headers
.TryAddWithoutValidation("Accept","multipart/related;type=application/octet-stream");`
User contributions licensed under CC BY-SA 3.0