Search code examples
c#node.jsnancyself-hosting

Get rid of "The requested resource [path] does not match convention mapped to '/Content'"


I'm working with a self-hosted Nancy App, using it as an Api.

I published it on my server and now i'm working on a web-apps supposed to use this API.

The problem occurs when I'm requesting GET http://myApi:[port]/api/token.

When I test this using postman i get this :

  • StatusCode : 200
  • response Body contains the token i asked for

And when I'm using my web-app I get this in the nancy request-tracing :

  • StatusCode : 500
  • Log message :

    [StaticContentConventionBuilder] The requested resource '/api/token' does not match convention mapped to '/Content'

So, if i understood what it means : On the 2nd request Nancy is trying to serve static Content and that's not what i want him to do since i just want to send back a json with my token.

I encountered a few topics where it's said that we can change the behaviour of the staticContentConventionsBuilder but most of it are just changing the static content folder.

I made sure that my request and response should have Content-type : application/json in header.

Postman request and web-apps request weren't made from the same machine but are part of the same networks and CORS are allowed.


Solution

  • So it seems that adding one line in the request's header works for me. Here is the line I added : Accept : "*/*;q=1"

    It's part of the header that postman send on every request.

    You can find an explanation of this here :

    purpose of the Q value in Accept header

    or in the link provided in the answer.