Query sparql endpoint giving HTTP Error 406: Not Acceptable

607 views
Skip to first unread message

Richard Dijkstra

unread,
Jul 2, 2020, 6:35:03 AM7/2/20
to rdfli...@googlegroups.com
Dear all,

I am querying a sparql endpoint and have an issue with that.

Using DBpedia works fine.
But using another endpoint build on Jena running on my own W10 machine I get the error
  
HTTP Error 406: Both format and output parameters are specified, which is not acceptible.

I have tried a lot already. What can be wrong?

My code in Python 3.8.2:

sparql = SPARQLWrapper(endpoint="http://localhost:8083/tbl/sparql",
defaultGraph="urn:x-evn-master:decomp_overijssel")

SELECT * WHERE
{?s ?p ?o}

results = sparql.query()

Kind regards,
Richard D

Wes Turner

unread,
Jul 2, 2020, 4:23:56 PM7/2/20
to rdfli...@googlegroups.com

On Thu, Jul 2, 2020, 6:35 AM Richard Dijkstra <richarddi...@gmail.com> wrote:
Dear all,

I am querying a sparql endpoint and have an issue with that.

Using DBpedia works fine.
But using another endpoint build on Jena running on my own W10 machine I get the error
  
HTTP Error 406: Not Acceptable

I have tried a lot already. What can be wrong?

Kind regards,
Richard D

--
http://github.com/RDFLib
---
You received this message because you are subscribed to the Google Groups "rdflib-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rdflib-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rdflib-dev/3f646773-0fc1-4f19-ab95-08d54f54da05o%40googlegroups.com.

Richard Dijkstra

unread,
Jul 3, 2020, 10:00:33 AM7/3/20
to rdflib-dev
Thank you Wes for the tips for further investigations. I will give it a try next week.

Regards,
Ruchard

Richard Dijkstra

unread,
Jul 6, 2020, 11:30:48 AM7/6/20
to rdflib-dev
I am not able to go to too much detail because my lack of knowledge of proper requests etc
But interesting might be that the Python library sparql-client queries the endpoint with no issues.

However I want to use SPARQLwrapper because it has more features.

Sergio Fernández

unread,
Jul 6, 2020, 11:44:24 AM7/6/20
to rdfli...@googlegroups.com
Please, report the details if the issue to GitHub, and we'll try to troubleshoot it.

--
http://github.com/RDFLib
---
You received this message because you are subscribed to the Google Groups "rdflib-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rdflib-dev+...@googlegroups.com.

Wes Turner

unread,
Jul 6, 2020, 12:47:05 PM7/6/20
to rdfli...@googlegroups.com
Yeah the difference is likely in the request body and request headers; so wrapping those in fenced code blocks in a GirHub Issue description would be most helpful.
Like this:

```http
GET /sparql?...
[...]
```


Richard Dijkstra

unread,
Aug 12, 2020, 7:40:38 AM8/12/20
to rdflib-dev
Sergio,

It was luckely just a user error. Apperently content negotiation is required:

sparql.setOnlyConneg(True)

did the trick.

So this code works fine to query and construct results from a local Topbraid EDG server:

    endpoint
= "http://localhost:8083/tbl/sparql"
    query
= """SELECT ?prop ?datatype
            WHERE {
                <http://example.org/ontologies/assetonto#Object> sh:property ?prop .
            OPTIONAL {
                ?prop sh:datatype ?datatype .
                }
                }"""


    sparql
= SPARQLWrapper(endpoint)
    sparql
.setQuery(query)

    sparql
.addDefaultGraph("urn:x-evn-master:assetonto")
    sparql
.setOnlyConneg(True)
    sparql
.setReturnFormat(CSV)
    result
= sparql.query().convert()


kind regards,
Richard

On Monday, July 6, 2020 at 5:44:24 PM UTC+2, Sergio Fernández wrote:
Please, report the details if the issue to GitHub, and we'll try to troubleshoot it.

On Mon., Jul. 6, 2020, 08:32 Richard Dijkstra <richarddi...@gmail.com> wrote:
I am not able to go to too much detail because my lack of knowledge of proper requests etc
But interesting might be that the Python library sparql-client queries the endpoint with no issues.

However I want to use SPARQLwrapper because it has more features.


On Friday, July 3, 2020 at 4:00:33 PM UTC+2, Richard Dijkstra wrote:
Thank you Wes for the tips for further investigations. I will give it a try next week.

Regards,
Ruchard

--
http://github.com/RDFLib
---
You received this message because you are subscribed to the Google Groups "rdflib-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rdfli...@googlegroups.com.

Wes Turner

unread,
Aug 12, 2020, 10:47:21 AM8/12/20
to rdfli...@googlegroups.com
How did you determine that sparql.setOnlyConneg(True) was the issue?

To unsubscribe from this group and stop receiving emails from it, send an email to rdflib-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rdflib-dev/e807c91b-e35f-4cc2-b490-f95bbc9650ffo%40googlegroups.com.

Sergio Fernández

unread,
Aug 12, 2020, 11:01:00 AM8/12/20
to rdfli...@googlegroups.com
So very different interpretations of the protocol... that's why the client has so much code that would not be necessary in an ideal world :-/

To unsubscribe from this group and stop receiving emails from it, send an email to rdflib-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rdflib-dev/e807c91b-e35f-4cc2-b490-f95bbc9650ffo%40googlegroups.com.

Wes Turner

unread,
Aug 12, 2020, 11:45:30 AM8/12/20
to rdfli...@googlegroups.com
Good to hear you got it figured out

Richard Dijkstra

unread,
Aug 12, 2020, 12:56:56 PM8/12/20
to rdfli...@googlegroups.com
I found it by a Google search resulting in some code that had some of these Sparql settings. By luck this worked. Then I started looking for default behaviour by eliminating explicite settings. setOnlyConneg has a default Setting False which was the 406 cause. From some extra testing no other setting was causing a 406.

We might add the possible options for accessing the Topbraid EDG server Sparql endpoint in the documentation. I believe their Sparql engine originates from Jena but has some extra capabilities.

Op 12 aug. 2020 om 16:47 heeft Wes Turner <wes.t...@gmail.com> het volgende geschreven:



Nicholas Car

unread,
Aug 30, 2020, 7:44:30 AM8/30/20
to rdfli...@googlegroups.com
Hi all,

We use SPARQL queries with EDG all the time since my company uses EDG as the basis for some of our products, so let me know if you have any problems accessing EDG via SPARQLWrapper.

Also, I hope to run a small SPARQLWrapper sprint soon as the codebase is in need of a touch-up. A bunch of PRs are failing tests and I think some of the failures are false in some way. The failures make passing PRs impossible and prevent me from lodging more - I have one to turn XML responses from a SimpleXml object into a Python dict, just as JSON responses are converted - but need to see the exisiting, backed-up PRs dealt with first.

My plans for SPARQLWrapper:

1. Check to see why all existing PRs fail some, but mostly not all, Python version tests 

2. Check all modern triplestore SPARQL endpoints, and modern versions of them, are represented in test suite

3. Update to Python 3.6+ only in next release (to match main rdflib package)

4. Update documentation - not all possible configurations are documented well, as shown by this thread

Would love any help with this!

Cheers,

Nick


— 
Dr Nicholas Car
Data Systems Architect
SURROUND Australia
0477 560 177

On 13 Aug 2020, at 2:56 am, Richard Dijkstra <richarddi...@gmail.com> wrote:



Wes Turner

unread,
Aug 30, 2020, 9:51:38 AM8/30/20
to rdfli...@googlegroups.com
There are many ways to set up each and every major SPARQL server.

Tox envs for each database may be the way to go. 

A test grid with GitHub Actions and separate containers may be the easiest thing; but IDK that the whole grid needs to be run every time.

## Tox docs


Rather than writing the PID and shutting the external process down in e.g. tox commands_post, there's pytest-xprocess:

Here's how SQLAlchemy and Django test multiple databases with tox:


## Containers, Docker, and Podman
Containers can contain already-configured databases (with data already loaded).

Podman containers run as a subprocess.

Podman may be installed in a container on a CI system. With CentOS and Fedora, it's just `dnf install -y podman` and then configuration of containers so that they'll run as rootless containers.

With containers as subprocesses, the build and test would run once in one container and launch each database as a [rootless] sub-container, run tests, and then shut down the server (thus not using unnecessary resources for every build).

It looks like the SQLAlchemy tox.ini also accomplishes that somehow in a different way?


## GitHub Actions

An actions.yml for GitHub Actions which installs SPARQLwrapper into successive containers for each database (rather than trying to install every database within the test container) may be the easiest thing.

https://github.com/sdras/awesome-actions#database doesn't yet list much in the way of testing a grid of versions and database versions.

https://freek.dev/1590-how-to-use-a-mysql-database-on-github-actions describes how to add a `service:` dependency on a MySQL image (which presumably unnecessarily runs for the duration of the test run?)


https://github.com/ymyzk/tox-gh-actions#advanced-examples describes how to use Factor-conditional settings

Nicholas Car

unread,
Sep 4, 2020, 7:01:22 AM9/4/20
to rdfli...@googlegroups.com
Thanks for all those tips Wes!

I’m on leave this week but some time next week I’ll read some of those and make more of a SPARQLWrapper plan and announce that. Then I’ll ask for volunteers for plates of it...

Cheers,

Nick 

— 
Dr Nicholas Car
Data Systems Architect
SURROUND Australia
0477 560 177

On 30 Aug 2020, at 11:51 pm, Wes Turner <wes.t...@gmail.com> wrote:


Reply all
Reply to author
Forward
0 new messages