Hi Stardog Community,
I’m encountering an issue when querying a Stardog SPARQL endpoint and would appreciate your insights or suggestions. Below are the details:
Endpoint:
https://sd-d8db509a.stardog.cloud:5820/JTH-Product-Data
Problem Description
While performing SPARQL queries from different clients and environments, I noticed inconsistent behavior regarding response formats:
- Using the SERVICE keyword in GraphDB:
SELECT * WHERE {
SERVICE <https://sd-d8db509a.stardog.cloud:5820/JTH-Product-Data> {
<http://example.org/fagerhult_notor_product_data#7320046635763> ?property ?value .
}
}
Result:
500: Error Query evaluation error: Unsupported Media Type
- Using dotNetRDF's SparqlRemoteEndpoint.QueryWithResultSet method:
SparqlRemoteEndpoint endpoint = new SparqlRemoteEndpoint(new Uri("https://sd-d8db509a.stardog.cloud:5820/JTH-Product-Data"));
endpoint.Credentials = new System.Net.NetworkCredential("**user**", "**pwd**");
SparqlResultSet results = endpoint.QueryWithResultSet("SELECT ?property ?value WHERE { <http://example.org/fagerhult_notor_product_data#7320046635763> ?property ?value }");
Result:
Exception: "Unable to Parse a SPARQL Result Set from the provided XML since the Document Element is not a
element!"
- Using dotNetRDF's SparqlRemoteEndpoint.QueryRaw method:
Observation:
The raw HTTP response has aContent-Type
header set totext/turtle
.
I also tried setting the Accept
header explicitly to application/sparql-results+json
, but the response format didn’t change and remained text/turtle
.
Working Solution
The only method that worked was using the StardogConnector
class from dotNetRDF:
StardogConnector connector = new StardogConnector("https://sd-d8db509a.stardog.cloud:5820/JTH-Product-Data", "**user**", "**pwd**");
SparqlResultSet results = connector.Query("SELECT ?property ?value WHERE { <http://example.org/fagerhult_notor_product_data#7320046635763> ?property ?value }");
Key Question:
According to the SPARQL 1.1 Protocol, the specified response formats for SPARQL queries should include XML, JSON, and CSV/TSV.
Why is Stardog returning text/turtle
instead of one of the standard formats?
Is there a way to enforce the response format (e.g., JSON or XML) when querying the endpoint?
Any guidance or suggestions would be greatly appreciated!
Thanks in advance!
Best regards,
Rahel