Issuing POST request with credentials via SPARQLStore #1601
Replies: 2 comments
-
In about 10 days: 5.0.0 is due out on the 3rd of April! Sorry I can't answer the other questions yet but getting this release out is Priority 1 for now, We, the new rdflib maintainers, will need some more time to get comfortable with toolkit part details and expected partterns of use (I personally haven't used the SPARQLUpdateStore). |
Beta Was this translation helpful? Give feedback.
-
@stevemn I ran into some similar issues the other day. Here's a post (https://edmondchuc.com/rdflib-sparqlupdatestore-5-0-0/) with my working code to add triples to an external RDF store via a SPARQL endpoint. Summary
Does your RDF store's SPARQL endpoint support POST requests using headers = {
"content-type": "application/sparql-update"
}
SPARQLUpdateStore('http://endpoint/query', 'http://endpoint/update', headers=headers, auth=("your_username", "your_password") Passing in the auth credentials like this is only for basic auth. If you need something else like Digest auth, then you need to import from |
Beta Was this translation helpful? Give feedback.
-
Hello-
I am using RDFLib 4.2.2, and I'm having an issue using the SPARQLUpdateStore to query a SPARQL endpoint over HTTP. This seems related to issue #755, but I would still appreciate clarification. There's a lot here, and the ultimate conclusion may be "Don't use SPARQLUpdateStore", so please feel free to skip to the end where I ask my questions.
Problem
The endpoint I am hitting expects both queries and updates to be submitted via POST. Included in the message body are parameters for
'email'
and'password'
, along with a 3rd parameter for the query or update body. I've used SPARQLWrapper for this sort of operation in the past, and the following process completes with the expected results:Using the Store interface promises to remove one more import/dependency, so I'd prefer to use that. The first issue I run into is that the SPARQLStore and SPARQLUpdateStore classes in 4.2.2 differ from their current state on the master branch. This is noted in pull request #744; namely, the removal of the SPARQLWrapper dependency. For me, this is actually a non-issue, since the older version of SPARQLStore inherits from SPARQLWrapper, and so I should be able to use the same process. All the following works as expected:
Here is where my real issue begins. Calling
su.queryAndConvert()
fails with the following (I'll provide full tracebacks at the end):SPARQLStore is overriding the query method, and the signature has changed. The function expects the query string to be passed in as an argument, rather than accessing it on the object as SPARQLWrapper does. Easily fixed; I now call
su.query(su.queryString)
. Here, I get the following; same exception as #755, and the main knot I'm dealing with:After some fiddling, I discover that, prior to issuing any queries, both the Wrapper and Store objects produce the same request data when the
_createRequest
method is called:Once the
su.query(su.queryString)
method fails, the request data is now completely empty:Using IPython's introspection, I believe I narrow this down to the following section of
SPARQLStore.query
:It appears that the
resetQuery
call is dropping all of the parameters I have set prior to issuing the request, which would explain why the query is returning a 403 Forbidden. This is where I'm stuck now, so finally:Questions
Thanks and keep up the great work-
Steve
Full tracebacks
su.queryandConvert()
su.query(su.queryString)
Beta Was this translation helpful? Give feedback.
All reactions