title: Posting an XML to WebAPI and return a result
body: <p>So I have been struggling to get this work for some time now.
  Let me explain the requirement.
  I have to write a WebAPI that will accept an XML, do some look up, and return a response.</p>
  
  <p>I am new to this so sought some help. The suggestion was to create a custom object that represents the incoming XML
  and use that object as the param for the method exposed by the WebAPI.
  The result will be a class that's not a problem.</p>
  
  <p>Here are the steps done.</p>
  
  <p>Created an empty WebAPI project.
  Added a class that represents the incoming XML.</p>
  
  <p>Incoming XML:</p>
  
  <pre><code>&lt;InComingStudent&gt;
  &lt;StudentID&gt;10&lt;/StudentID&gt;
  &lt;Batch&gt;56&lt;/Batch&gt;
  &lt;/InComingStudent&gt;
  </code></pre>
  
  <p>The class:</p>
  
  <pre><code>public class InComingStudent
  {
      public string StudentID { get; set; }
      public string Batch { get; set; }
  }
  </code></pre>
  
  <p>Return object of this type:</p>
  
  <pre><code>public class StudentResult
  {
      public string StudentID { get; set; }
      public string Batch { get; set; }
      public string Score { get; set; }
  }
  </code></pre>
  
  <p>Added a Students controller with this method:</p>
  
  <pre><code>public class StudentsController : ApiController
  {
      [HttpPost]
      public StudentResult StudentStatus(InComingStudent inComingStudent)
      {
  
          ProcessStudent po = new ProcessStudent();
          StudentResult studentResult = po.ProcessStudent();
          return StudentResult;
      }
  }
  </code></pre>
  
  <p>Ran the service. It opened in a new browser with 404. That's ok as I don't have a starting page.</p>
  
  <p>Wrote a console app to test:</p>
  
  <pre><code>private static async void PostToStudentService()
  {
      using (var client = new HttpClient())
      {
          var studentToPost = new InComingStudent() { StudentID = "847", Batch="56"};
          client.BaseAddress = new Uri("http://localhost:53247/");
          client.DefaultRequestHeaders.Accept.Clear();
          client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml"));
  
          HttpResponseMessage response = await client.PostAsXmlAsync("api/Students/StudentStatus", studentToPost);
  
          if (response.IsSuccessStatusCode)
          {
              // Print the response
          }
      }
  }
  </code></pre>
  
  <p>MediaTypeWithQualityHeaderValue is set to application/xml.
  So far so good.
  When the service is running and I run the console app, the response is 404 "Not Found".</p>
  
  <p>What am I missing?</p>
  
  <p>Any help is greatly appreciated.</p>
  
  <p>Regards.</p>