Reputation: 34297
I'm getting a 404 Not Found
when making this call:
var url = rootWebApiUrl + '/folders/' + $scope.selectedServer.Name + "/" + serviceName;
$http.get(url) // the rest of this line doesn't matter for this issue
I thought that maybe using encodeURIComponent
would help, but I get the same 404 Not Found
error:
var url = rootWebApiUrl + '/folders/' + $scope.selectedServer.Name + "/" + encodeURIComponent(serviceName);
This is the Web API Method Signature:
[Route("folders/{serverName}/{serviceName}")]
[HttpGet]
public IEnumerable<Folder> Folders(string serverName, string serviceName)
The first option (above) works if I change the service name while debugging. The original service name is Company Name Message Bus Manager 3.6 - MesFinishingEvents
. If I change it to something with no spaces, like snuh
, then the Web API call succeeds and I can debug in the Web API method.
How can I pass the original service name in my $http.get(url)
call?
Edit: URL values:
With service name that has spaces:
http://localhost:4153/api/services/folders/ServerName/Company%20Name%20Message%20Bus%20Manager%203.6%20-%20MesFinishingEvents
Using a simple service name:
http://localhost:4153/api/services/folders/ServerName/snuh
Upvotes: 2
Views: 2158
Reputation: 7740
WebAPI controllers struggle when you have a .
in your parameters, here and here.
Your method call would work all the way up to:
http://localhost:4153/api/services/folders/ServerName/Company%20Name%20Message%20Bus%20Manager%203
and beyond, if the period didn't exist.
The quickest solution is to add a trailing slash. The longer solution would be to modify your sites HTTP handlers in IIS.
Upvotes: 3