Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebApi method with email address parameter returns 404 from HttpClient

I have a WebApi controller with a method that looks like such:

[HttpGet] [AcceptVerbs("GET")] public HttpResponseMessage Run(string reportName, int someId, string someText, DateTime asOfDate, string username) 

I have a custom route configured specifically for this action. When I navigate my browser to the web service, everything works fine, and the appropriate action is executed:

http://localhost:xxxx/ControllerName/Run/asdf/1/asdf/07-01-2012/[email protected] 

However, when I attempt to programatically call the web service using the HttpClient and executing a "Get" I get a 404 error. I don't get an error when the username parameter is not an email address. For example, when the username is just "user" everything works fine. Here is the sample code:

var url = "http://localhost:xxxx/ControllerName/Run/asdf/1/asdf/07-01-2012/[email protected]" var client = new System.Net.Http.HttpClient(); var response = client.Get(url);  //fails here with 404 error response.EnsureSuccessStatusCode(); 

I have tried UrlEncoding the email address with no luck. Any advice is appreciated.

like image 850
Matt Wolin Avatar asked Aug 06 '13 16:08

Matt Wolin


1 Answers

Just a quick thought... could the ".com" be causing the issue?

like image 190
Ryan Ferretti Avatar answered Sep 20 '22 15:09

Ryan Ferretti