Confused Development

I develop software and I often get confused in the process. I usually find the answers after a while, but a month later I can't remember them. So from now on, I will write them down here.

Friday, October 29, 2010

Using CURL to access a SPARQL endpoint

You can use the command line tool curl to access a SPARQL endpoint, e.g. from Sesame 2. Just do like this:

curl -H "Accept: application/sparql-results+xml" "http://REPOSITORY_URI?query=ESCAPED_QUERY"

The interesting bit is the -H parameter, where you specify header information. What you do here is to tell the endpoint what kind of result format you accept. I always forget how to do that...

Edit:

To get JSON back, the mimetype has to be application/sparql-results+json, at least on SESAME 2. This mimetype was defined in this W3C note.

Labels: , , , , , ,