title: Net Web API - How to pass a URL as input parameter on a Get
body: <p>I am trying to pass a URL as a input parameter to a ApiController from an Angular REST call. The URL comes as a query string (this is a Provider Hosted app in SharePoint, I need the URL to query SP FWIW). </p>
  
  <p>Here is the method signature in the ApiController:</p>
  
  <pre><code>// GET: api/ProjectSite/5
  public IEnumerable&lt;ProjectSite&gt; Get(string id)
  {
      return ProjectSite.GetAllProjectSites(id);
  }
  </code></pre>
  
  <p>And here is where I am making the call in Angular:</p>
  
  <pre><code>var spUrl = "'" + getParameterByName("SPHostUrl") + "'";
  
  var queryUrl = "/api/ProjectSite/" + encodeURIComponent(spUrl);
  return $http.get(queryUrl);
  </code></pre>
  
  <p>This generates a GET request that looks like this:</p>
  
  <p><a href="https://localhost:12345/api/ProjectSite/https%3A%2F%2Fcompany.sharepoint.com%2Fsites%2Fsite_dev%2Fweb" rel="noreferrer">https://localhost:12345/api/ProjectSite/https%3A%2F%2Fcompany.sharepoint.com%2Fsites%2Fsite_dev%2Fweb</a></p>
  
  <p>When I do I get 'HTTP 400 (Bad Request)' back. If I stop on a break point in the Angular code and change the input param to a simple string (e.g. 'asdf') the REST call is made and I see the Api is called. If I do not change the string and put a breakpoint inside the Get Api method the breakpoint is not reached, indicating that the code is blowing up somewhere in the route engine. </p>
  
  <p>What I don't get is, while its encoded, the string I am trying to pass in should still be treated as a string, right? I also tried changing the input to Uri but that doesn't appear to work (and Uri isn't listed as a supported input type, anyways).</p>
  
  <p>Anyone know how to pass a URL as input parameter? </p>