public HttpRequestMessage GetHttpRequestMessage() { var message = new HttpRequestMessage(new HttpMethod(HttpMethod), Url); message.SetRequestContext(GetHttpRequestContext(message)); if (RequestData != null) { message.Content = new ByteArrayContent(RequestData); } else { message.Content = new HttpMessageContent(message); } if (ContentType.IsNotNullOrEmpty()) { message.Content.Headers .ContentType = new MediaTypeHeaderValue(ContentType); } if (Accept.IsNotNullOrEmpty()) { message.Headers.Add("Accept", Accept); } if (AttachmentFilename.IsNotNullOrEmpty()) { message.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment") { FileName = AttachmentFilename } } ; return(message); }