当前位置: 动力学知识库 > 问答 > 编程问答 >

Neo4j REST API Get request from browser vs Get method from REST Client

问题描述:

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.

This is the response I got.

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!

网友答案:

They use media type negotiation header. For example when requesting this site my browser send 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 being served 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 specifies application/json, or nothing at all (the application determines the default media type then), hence the response.

分享给朋友:
您可能感兴趣的文章:
随机阅读: