Reputation: 3301
Neo4j API url is: http://localhost:7474/db/data
When I use Chrome visiting this url, which is a GET request. This is the response I got
But when I use the restful client such as POSTMAN to make a g request.
My questions are
Both are GET request to the same url. Why Chrome browsing get a html page in return but Postman Request get JSON Response in return.
How Neo4j does that?
Is Neo4j using user agent detection, and if it is a browser visiting, it will give HTML page as response. And if it is a rest client request, it will give json response?
Thanks!
Upvotes: 0
Views: 753
Reputation: 1654
They use media type negotiation header. For example when requesting this site my browser sends a header like that:
Accept: "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
As you can see it accepts primarily html
, if that's not available then xhtml
, then pure xml
, and if that's not available - it accepts whatever the server can throw at it. Neo4j
's website tries to serve content in that order. Postman likely just specifies application/json
, or nothing at all (the application determines the default media type then), hence the response.
Upvotes: 1