title: The Constraint Entry 'httpMethod' on the Route Must Have a String Value
body: <p>I have an asp.net Web API project, and in my <code>WebApiConfig</code> file, I have the following route defined:</p>
  
  <pre><code>config.Routes.MapHttpRoute(
      name: "Web API Get",
      routeTemplate: "api/{controller}",
      defaults: new { action = "Get" },
      constraints: new { httpMethod = new HttpMethodConstraint("GET") }
      );
  </code></pre>
  
  <p>For integration testing purposes, I want to make a request to an <code>HttpSelfHostServer</code> to verify that we are receiving the proper data back from the api call. I am making the <code>HttpRequestMessage</code> as follows:</p>
  
  <pre><code>var httpMethod = new HttpMethod("GET");
  var request = new HttpRequestMessage(httpMethod, "http://localhost:XXXX/api/User/");
  var results = _client.SendAsync(request).Result;
  </code></pre>
  
  <p>I would expect that this would call the Get method on the UserController and then return the results as defined in that method. However, I instead get the following exception:</p>
  
  <p><strong>System.InvalidOperationException: The constraint entry 'httpMethod' on the route with route template 'api/{controller}' must have a string value or be of a type which implements 'IHttpRouteConstraint'</strong></p>
  
  <p>This same url (<code>http://localhost:XXXX/api/User/</code>) works without error when I use it in the browser, so I am pretty sure the issue has to be in the way I am sending the request to the <code>HttpSelfHostServer</code> through the <code>HttpClient</code>. I have tried using the <code>HttpMethod.Get</code> constant instead, but that also threw the same error.</p>
  
  <p>Does anyone have any idea how I could resolve this issue?</p>