title: How to deal with routing conflicts on WebAPI - string IDs vs action + id
body: <p>I am hosting a REST API using Web API on .NET 4 (WebAPI version 4.0.30506 on nuget).  To allow for more elaborate attribute routing, I've also included <a href="http://attributerouting.net/" rel="nofollow">attributerouting.net</a> in my solution.  </p>
  
  <p>I have 2 attribute routes that are conflicting.  The reason for the conflict is that we are querying by a string identifier in one call, and querying by a string action + numerical identifier in another. The message thrown in the HTTP response reads <code>Multiple actions were found that match the request</code>.  Here are sample queries to demonstrate both of them:</p>
  
  <pre><code>1) http://example/api/libraries/?libraryId=some_library (some_library is a string identifier)
  
  2) http://example/api/libraries/bookStatus/1 (1 is the library database ID) 
  </code></pre>
  
  <p>I've been struggling with different ways to make this work.  My current controller signatures look like this:</p>
  
  <pre><code>[GET("api/libraries/?libraryId={libraryId}", Precedence = 2)]
  [System.Web.Http.HttpGet]
  public Library QueryLibraryByLibraryId(string libraryId){}
  
  [GET("api/libraries/bookStatus/{libraryId:long}", Precedence = 1)]
  [System.Web.Http.HttpGet]
  public Dictionary&lt;string, Dictionary&lt;string, string&gt;&gt; QueryBookStatus(long libraryId){}
  </code></pre>
  
  <p>I can see why the routing might get confused: How does it know that the string identifier of <code>"bookStatus/1"</code> is invalid is a fine question to ask. However, I figured this should be easier to define some constraints around.</p>
  
  <p>How do I resolve these conflicts while maintaining this type of signature structure?</p>