public HttpResponseMessage DownloadFile([FromUri] string id) { string authorizationString = DecodeAuthorizationString(); SPHelper.SetSharePointCredentials(authorizationString); ListItem item = SPHelper.FindFile(id.ToGuid()); string fileName = item["FileLeafRef"].ToString(); string contentType = System.Web.MimeMapping.GetMimeMapping(fileName); HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK); Byte[] bytes = SPHelper.DownloadFile(item); response.Content = new ByteArrayContent(bytes); response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment"); response.Content.Headers.ContentType = new MediaTypeHeaderValue(contentType); response.Content.Headers.ContentDisposition.FileName = fileName; return(response); }