Hi all
I'm trying to set up a very simple HTTP python query to my Stardog database but have been banging my head against the wall for 2 days now. I have a DB set up called CompHawkDB using the default security settings (user: admin, pass: admin)
Here's the code I'm using:
import requests
import urllib.parse
headers = {
'SD-Query-Bindings': '',
'SD-Connection-String': '',
}
query = {'query' : 'SELECT ?s WHERE { ?s ?p ?o .}'}
print(request_url)
r = requests.get(request_url, headers=headers, auth=('admin', 'admin'))
print(r.status_code)
print(r.headers)
print(r.text)
But when I run this code I get the following output:
http://localhost:5820/CompHawkDB/query?query=SELECT+%3Fs+WHERE+%7B+%3Fs+%3Fp+%3Fo+.%7D
400
CaseInsensitiveDict({'server': 'Stardog/2.1.2/v4', 'content-length': '52'})
A JSONObject text must begin with '{' at character 0
If I change the request_url to the size line then the code runs just fine:
http://localhost:5820/CompHawkDB/size
200
CaseInsensitiveDict({'content-encoding': 'gzip', 'content-type': 'text/plain', 'transfer-encoding': 'chunked'})
44972
Can anyone here help me out? I've tried adding more header fields like "Accept" and "Content-Type" but they all come back with the same problem:(
- What is wrong with the way that I'm doing the query?
- How come 'SD-Error-Code' is not returned as part of the header in either cases?
Thanks in advance!
James