title: How to pass xml to Asp.net Web Api 2 Get function
body: <p>Just been stuck here for long time now. Thought someone might be able to put me in right direction. I have created a ASP.NET Web API 2 application. There is one function which will return all ships. Now I want to receive an xml inside my controller function. How can I achieve that. Below is my HttpClient calling code which is giving me Bad Request error. Can someone guide me in right direction to how to pass xml to Web api function.</p>
  
  <p>Routing</p>
  
  <pre><code>public static void Register(HttpConfiguration config)
          {
              // Web API configuration and services
  
              // Web API routes
              config.MapHttpAttributeRoutes();
  
              config.Routes.MapHttpRoute(
                  name: "DefaultApi",
                  routeTemplate: "api/{controller}/{id}",
                  defaults: new { id = RouteParameter.Optional }
              );
          }
  </code></pre>
  
  <p>Controller Action</p>
  
  <pre><code>public IHttpActionResult GetSummaryFunction(string id)
          {
              return Ok(id);
          }
  </code></pre>
  
  <p>Client Code</p>
  
  <pre><code>HttpClient client = new HttpClient();
              client.BaseAddress = new Uri("http://localhost:53633/");
  
              client.DefaultRequestHeaders.Accept.Add(
                  new MediaTypeWithQualityHeaderValue("application/xml"));
  
              string testXml = "&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;&lt;SummaryRQ  xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://schemas.datacontract.org/2004/07/Test.WebAPI.Controllers\" Version=\"1.00\" Target=\"Test\"&gt;&lt;POS&gt;&lt;Source Login=\"test\" Password=\"test\"&gt;&lt;/Source&gt;&lt;/POS&gt;&lt;/SummaryRQ&gt;";
  
              var url = "api/summaryfunction/" + testXml;
  
              HttpResponseMessage response = client.GetAsync(url).Result;
  
              if (response.IsSuccessStatusCode)
              {
                  var result = response.Content.ReadAsStringAsync().Result;
              }
              else
              {
  
              }
  </code></pre>