0

I am trying to pass in URL as a Parameter in REST Service.

Request: https://LocalHost/api/InsertUrl/{Type},{URL},{Notes} https://LocalHost/api/InsertUrl/External,https://www.amazon.com,RANDOM NOTE

Sample Code:

[HttpPost]
[Route("api/InsertUrl/{Type},{URL},{Notes}")]
public bool SetUrl(string Type, string URL, string Notes)
{

    bool Status = repository.SetupUrl(Type, URL, Notes);
    return Status ;

}

Using POSTMAN (with POST) to test this end point I am getting :: 404 - File or directory not found. The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.

What am I doing wrong here?

George Chondrompilas
  • 3,167
  • 27
  • 35
  • Have you tried using POST method ? GET method will not work for this – Thanigainathan Nov 03 '17 at 15:10
  • And then, some hacker calls your URL with a malicious URL. *Why* do you want to pass the URL this way? – Panagiotis Kanavos Nov 03 '17 at 15:46
  • `[HttpPost]`. This isn't a *GET* method, this is a POST. `GET` is supposed to *get* resources, not make changes. You should remove the parameters from the `Route` attribute and change your client code to send everything as a POST parameter – Panagiotis Kanavos Nov 03 '17 at 15:47

1 Answers1

0

IIS doesn't like the dots in the URL, thinking that if it file extension and has to go through another module.

To avoid this you can route all requests through your application:

 <configuration>
    <system.webServer>
        <modules runAllManagedModulesForAllRequests="true" />

This problem is actually already answered in another post here.

mcsdwarken
  • 109
  • 3