# Getting turtle instead of json

**URL:** <https://community.stardog.com/t/getting-turtle-instead-of-json/226>\
**Category:** Support\
**Created:** [April 11, 2017, 3:02am UTC](https://community.stardog.com/t/getting-turtle-instead-of-json/226 "2017-04-11T03:02:04Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ChipNowacek](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/chipnowacek/32/55_2.png) [@ChipNowacek](https://community.stardog.com/u/ChipNowacek)\
**Post date:** [April 11, 2017, 3:02am UTC](https://community.stardog.com/t/getting-turtle-instead-of-json/226/1 "2017-04-11T03:02:04Z")

</div>

Set MIME type in request to `application/sparql-results+json` and I'm getting turtle back. What am I screwing up?

 ![](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/1X/f45578846c6eb30e5dc0d9649e9695bbca63e85c.png)

---

<div class="post-metadata">

**Author:** ![stephen](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/stephen/32/27_2.png) [@stephen](https://community.stardog.com/u/stephen)\
**Post date:** [April 11, 2017, 1:26pm UTC](https://community.stardog.com/t/getting-turtle-instead-of-json/226/2 "2017-04-11T13:26:56Z")

</div>

What sort of query are you running? If you’re running a SELECT query, then `application/sparql-results+json` is a valid Accept type, however if you’re doing a CONSTRUCT, then you can only get back an RDF format such as `text/turtle`.

Having the `*/*` in your Accept header means the server will give you back anything. If you’re running a CONSTRUCT query and did not have the `*/*`, you would get back a 406 Not Acceptable response.

---

<div class="post-metadata">

**Author:** ![ChipNowacek](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/chipnowacek/32/55_2.png) [@ChipNowacek](https://community.stardog.com/u/ChipNowacek)\
**Post date:** [April 11, 2017, 1:32pm UTC](https://community.stardog.com/t/getting-turtle-instead-of-json/226/3 "2017-04-11T13:32:43Z")

</div>

```
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#> 
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> 

select distinct ?entity ?elabel ?type ?tlabel 
where { 
	?entity a owl:NamedIndividual . 
	OPTIONAL { ?entity rdfs:label ?elabel } . 
	OPTIONAL { ?type rdfs:label ?tlabel } 
}
```

---

<div class="post-metadata">

**Author:** ![ChipNowacek](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/chipnowacek/32/55_2.png) [@ChipNowacek](https://community.stardog.com/u/ChipNowacek)\
**Post date:** [April 11, 2017, 1:40pm UTC](https://community.stardog.com/t/getting-turtle-instead-of-json/226/4 "2017-04-11T13:40:11Z")

</div>

I got the above results using `d3.xhr`. I’m trying to work around using stardog.js.

---

<div class="post-metadata">

**Author:** ![stephen](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/stephen/32/27_2.png) [@stephen](https://community.stardog.com/u/stephen)\
**Post date:** [April 11, 2017, 2:31pm UTC](https://community.stardog.com/t/getting-turtle-instead-of-json/226/5 "2017-04-11T14:31:18Z")

</div>

I think the issue might be the endpoint you’re using. It appears that your request is going to `http://localhost:5820/naut#!/query/<URLEncoded query>`. Unless you’re using the web console (which it sounds like you aren’t), the `#!` would have no reason to be in the URL.

Try sending your request to the HTTP query endpoint and pass the query in on a query param like so: `http://localhost:5820/naut/query?query=PREFIX+rdf%3A+%3Chttp%3A%2F%2Fwww.w3.org...`

---

<div class="post-metadata">

**Author:** ![ChipNowacek](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/chipnowacek/32/55_2.png) [@ChipNowacek](https://community.stardog.com/u/ChipNowacek)\
**Post date:** [April 11, 2017, 2:59pm UTC](https://community.stardog.com/t/getting-turtle-instead-of-json/226/6 "2017-04-11T14:59:49Z")

</div>

That was it. I was using the web console URL and clearly shouldn’t have.

Thank you very much.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/2X/e/ed66b48a616f505106a4acde3c9cee7e6da9bc67.svg) [@system](https://community.stardog.com/u/system)\
**Post date:** [April 25, 2017, 3:07pm UTC](https://community.stardog.com/t/getting-turtle-instead-of-json/226/7 "2017-04-25T15:07:14Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
