REST API Content-Type header not recognised



I can’t seem to get the REST API to recognise the Content-Type header when doing a GET request to the /graph/match API.
I’ve tried both application/json/hal and application/graql as these are mentioned in the docs here:

It’s clearly returning the right answer and in json (i.e. application/json/hal I presume), but the headers come back as:

Content-Type →text/html;charset=utf-8
Date →Mon, 06 Mar 2017 19:29:32 GMT
Server →Jetty(9.3.6.v20151106)
Transfer-Encoding →chunked

and the response comes back as:  [{"_baseType":"ENTITY","_links":{"self":{"href":"/graph/concept/61504?keyspace=grakn"},"ontology":[{"href":"/graph/concept/ontology/61504?keyspace=grakn"}]},"_embedded":{"identifier":[{"_direction":"OUT","_baseType":"RESOURCE","_links":{"self":{"href":"/graph/concept/49392?keyspace=grakn"},"ontology":[{"href":"/graph/concept/ontology/49392?keyspace=grakn"}]},"_type":"identifier","_value":"Mary Guthrie","_id":"49392"}],"parent":[{"_direction":"IN","_baseType":"generated-relation","_links":{"self":{"href":"/graph/match?keyspace=grakn&query=match $x id '61504'; $y id '119032'; $ ...........

So issue 1: the Content-Type header in the response is text/html not application/json/hal. But the real issue for me at the moment is: I’d like to see what ‘application/graql’ looks like but when I set the header I still get text/html and the exact same json response.

I’m far from an expert at this so it’s likely I’m just doing something wrong. I’m using Postman to make the request, but I’ve also tried the equivalent curl command and get the same results.

Any help would be much appreciated!


Steps to reproduce:

docker run -dt -v $(pwd)/db/:/grakn/db/ -p 4567:4567 --name GRAKN graknlabs/grakn
sleep 10 #wait for things inside container to initialise
docker exec -it GRAKN /grakn/bin/ -f /grakn/examples/basic-genealogy.gql

curl -X GET -H “Content-Type: application/json/hal” “http://localhost:4567/graph/match?graphName=grakn&query=match%20(parent:%20%24p%2C%20child:%20%24c)%20isa%20parentship%3B%20%24p%20has%20identifier%20%24pi%3B%20%24c%20has%20identifier%20%24ci%3B%20%20limit%205%3B

curl -X GET -H “Content-Type: application/graql” “http://localhost:4567/graph/match?graphName=grakn&query=match%20(parent:%20%24p%2C%20child:%20%24c)%20isa%20parentship%3B%20%24p%20has%20identifier%20%24pi%3B%20%24c%20has%20identifier%20%24ci%3B%20%20limit%205%3B


Hello Mike!

It looks like we use the Accept header, not the Content-Type header determine the response. I’ll add a task to our internal tracking system to review this.

In the meantime, this will work if you want a Graql response:

curl -X GET -H "Accept: application/graql" "http://localhost:4567/graph/match?graphName=grakn&query=match%20%24x%20sub%20entity%20%3B"

This will work for HAL:

curl -X GET -H "Accept: application/json/hal" "http://localhost:4567/graph/match?graphName=grakn&query=match%20%24x%20sub%20entity%20%3B"

Apologies for the confusion!



Thanks Alex, I figured there was something obvious I was missing. Should have thought about the ‘Accept’ header! It’s working now, thanks a lot.

I have a few follow-up questions regarding using application/json/hal vs application/graql I’m hoping you can help me with. (Happy to split them out into a separate discuss question or chat via slack or a quick call if that’s easier).

Thanks a lot in advance



It’s best to split them into separate discussion post, @mikeleonard :slight_smile: It would help other community members to search and learn about the specific issues.


Makes sense :slight_smile:

Moved to here: Any example clients for REST API?


Perfect, I’ve amended your previous post! @mikeleonard