2

I am creating a GET Rest api

[HttpGet]
[Route("{email}")]
public async Task<IHttpActionResult> GetUsers(string email)
        {
           //rest of the code
        }

When I hit the api from Postman, it gave IIS 10.0 Detailed Error - 404.0 - Not Found

It works when I put a trailing '/' after the email in URL, but I don't want to use that, is there any other way to resolve this?

BlackCat
  • 1,932
  • 3
  • 19
  • 47
  • If you are providing "users", I'd suggest having the email as a querystring filter instead, like `/api/users?email=someEmail`. This is not an answer of course, just a suggestion on how to better model your route that could maybe work around the problem at the same time. – julealgon Mar 03 '23 at 20:45
  • Does this answer your question? [How do I allow URL encoded path segments in Azure](https://stackoverflow.com/questions/37178949/how-do-i-allow-url-encoded-path-segments-in-azure) – julealgon Mar 03 '23 at 20:47
  • So, it works when you call /test@test.com/ and doesn't work /test@test.com ? – godot Mar 03 '23 at 20:51
  • 1
    @godot correct.. dont work for /test@test.com – BlackCat Mar 03 '23 at 20:52
  • To fix this, you can modify your **routing configuration** to allow requests without the trailing slash. In your **WebApiConfig.cs** file, add the following line of code: `config.UrlTrailingSlashMode = System.Web.Http.TrailingSlashMode.Optional;` – Omer Huseyin GUL Mar 03 '23 at 20:53

0 Answers0