From: Jeff H. <ma...@gm...> - 2012-09-27 20:40:07
|
Greetings sparql-wrapper developers, I'm attempting the most basic sparql-wrapper (1.5.2) select query against a Sesame server repository (2.6.9) and am unable to get JSON back. I'm following the example code here: http://sparql-wrapper.sourceforge.net/. The response content-type is always application/xml. Why isn't application/json or sparql-results+json returned? Is this a bug in SPARQLWrapper otherwise what am I doing wrong? Does SPARQLWrapper.setReturnFormat(JSON) not work with Sesame? Incidentally I do get the proper JSON response using CURL from the cmd line using the following: curl -g -H "Accept: application/sparql-results+json;charset=UTF-8" http://localhost:8080/openrdf-sesame/repositories/test?query=select%20*%20where%20{%20?s%20?p%20?o%20}%20limit%205 Thanks, Jeff from SPARQLWrapper import SPARQLWrapper, JSON sparql = SPARQLWrapper("http://localhost:8080/openrdf-workbench/repositories/test") sparql.setReturnFormat(JSON) q = 'select * where { ?s ?p ?o } limit 5' sparql.setQuery(q) results = sparql.query().convert() # returns: /Users/Jeff/.virtualenvs/proto/lib/python2.7/site-packages/SPARQLWrapper/Wrapper.py:550: RuntimeWarning: unknown response content type, returning raw response... warnings.warn("unknown response content type, returning raw response...", RuntimeWarning) print results.info() # returns: Server: Apache-Coyote/1.1 Last-Modified: Thu, 27 Sep 2012 20:04:22 GMT Content-Type: application/xml;charset=UTF-8 Content-Length: 925 Date: Thu, 27 Sep 2012 20:15:30 GMT Connection: close results = sparql.query() print results.info() {'content-length': '925', 'server': 'Apache-Coyote/1.1', 'last-modified': 'Thu, 27 Sep 2012 20:04:22 GMT', 'connection': 'close', 'date': 'Thu, 27 Sep 2012 20:14:50 GMT', 'content-type': 'application/xml;charset=UTF-8'} |