Sitecore hosted on IIS, API returned 404 but has content

I have a Sitecore site and I’m trying to make API calls from a controller. For some reason API always returns the 404 not found, but it also executes the code correctly and returns the content. I tried to call the same API endpoint via Postman and returned the 200 code with content.

Here’s my RouteConfig:

routes.MapRoute("Feature.DataIntegration.Api", "api/dataintegration/{action}", new {     controller = "DataIntegration" }); 

Here’s my API (I tried to use [HttpGet] attribute, but it didn’t work):

public string test1() {     return "Asdas"; } 

This is my RestSharp code:

var url = "http://tdev.xxx.cd.local/api/dataintegration/test1"; var client = new RestClient(url); var request = new RestRequest(); IRestResponse response = client.Execute(request); 

This is Postman’s return: enter image description here

This is when the result from RestSharp (I also tried with httpclient, the same result): enter image description here

I have tried to disable my firewall, but doesn’t work neither.

How can I fix the 404 not found? If I don’t fix this, does this affect the API once deployed to a real server?

Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.