Lisp HUG Maillist Archive

accessing sparql endpoints via http requests

Dear lisp users,

I am not an experienced lisper yet, so sorry in advance if the question is not up to the standards :-)
I'm using LW on an intel mac (not leopard - for whatever difference it would make), and I've been trying to access a sparql endpoint 'manually', by creating the string-query myself and passing it via http to the endpoint.

Example: 

http://DBpedia.org/sparql?default-graph-uri=http%3A%2F%2Fdbpedia.org&should-sponge=&query=SELECT+%3Fperson%0D%0AWHERE+%7B+%3Fperson%3Chttp%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2Fname%3E+%22Platon%22%40de+%7D&format=text%2Fhtml&debug=on

This query over the DBpedia endpoint works well if done with a browser, but if I try to do it with DRAKMA, I get this error:


DRAKMA 32 : 4 > (http-request “http://DBpedia.org/sparql?default-graph-uri=http%3A%2F%2Fdbpedia.org&should-sponge=&query=SELECT+%3Fperson%0D%0AWHERE+%7B+%3Fperson%3Chttp%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2Fname%3E+%22Platon%22%40de+%7D&format=text%2Fhtml&debug=on“)

Error: Unknown protocol in “<?xml version=\“1.0\“ encoding=\“ISO-8859-1\“?>“.


Instead, if tried with sS-HTTP-CLIENT, it breaks here:


S-HTTP-CLIENT 19 : 5 > (do-http-request "http://DBpedia.org/sparql?default-graph-uri=http%3A%2F%2Fdbpedia.org&should-sponge=&query=SELECT+%3Fperson%0D%0AWHERE+%7B+%3Fperson%3Chttp%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2Fname%3E+%22Platon%22%40de+%7D&format=text%2Fhtml&debug=on")

Error: In 1+ of (NIL) arguments should be of type NUMBER.
   1 (continue) Return a value to use.


WHere do I get it wrong? I hope that the error is due only to my lack of knowledge and you guys and help me fixin it....


Cheers

Michele



p.s.

I know that there is TWINQL for doing sparql-stuff, but it's not well supported (in platforms other that Allegro) so I just wanted an easy solution to start with..



____________________________


Michele Pasin

Phd Student

Knowledge Media Institute

The Open University

Walton Hall

Milton Keynes

MK7 6AA

United Kingdom


Tel: 01908 858730

Email: m.pasin@open.ac.uk

< www.kmi.open.ac.uk/people/mikele >


 


Re: accessing sparql endpoints via http requests

>>>>> "mp" == Michele Pasin <m.pasin@open.ac.uk> writes:

  mp> http://DBpedia.org/sparql?default-graph-uri=http%3A%2F%
  mp> 2Fdbpedia.org&should-sponge=&query=SELECT+%3Fperson%0D%0AWHERE+%7B+%
  mp> 3Fperson%3Chttp%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2Fname%3E+%22Platon%22%
  mp> 40de+%7D&format=text%2Fhtml&debug=on
  mp> 
  mp> This query over the DBpedia endpoint works well if done with a
  mp> browser, but if I try to do it with DRAKMA, I get this error:
  mp> 
  mp> DRAKMA 32 : 4 > (http-request “http://DBpedia.org/sparql?default- 
  mp> graph-uri=http%3A%2F%2Fdbpedia.org&should-sponge=&query=SELECT+%
  mp> 3Fperson%0D%0AWHERE+%7B+%3Fperson%3Chttp%3A%2F%2Fxmlns.com%2Ffoaf%
  mp> 2F0.1%2Fname%3E+%22Platon%22%40de+%7D&format=text%2Fhtml&debug=on“)
  mp> 
  mp> Error: Unknown protocol in “<?xml version=\“1.0\“ encoding=
  mp> \“ISO-8859-1\“?>“.

  I was able to reproduce your problem on SBCL, so you should probably
  report it on the Drakma mailing list. If you write your request as
  
  CL-USER> (drakma:http-request "http://DBpedia.org/sparql?default-graph-uri=http%3A%2F%2Fdbpedia.org&should-sponge=&query=SELECT+%3Fperson+WHERE+%7B+%3Fperson%3Chttp%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2Fname%3E+%22Platon%22%40de+%7D&format=text%2Fhtml&debug=on")

  it works on SBCL. Drakma is rewriting the %0D%0A in your query as a
  newline character, and I suspect that it shouldn't be; I have
  replaced the "%0D%0A" by "+" to avoid the problem.

  You can debug this type of issue with a packet capture and analysis
  tool such as wireshark, or by asking Drakma to log HTTP headers
  using 

  CL-USER> (setq drakma:*header-stream* *standard-output*)

-- 
Eric Marsden


Re: accessing sparql endpoints via http requests

On Tue, 11 Dec 2007 21:43:00 +0100, Eric Marsden <eric.marsden@free.fr> wrote:

> Drakma is rewriting the %0D%0A in your query as a newline character,
> and I suspect that it shouldn't be

I also think this behaviour is wrong, but note that the rewriting is
actually done by the PURI library, so you should direct bug reports
there.  A temporary workaround could be to construct PURI URI objects
manually and hand them over as arguments to Drakma.

Edi.


Updated at: 2020-12-10 08:44 UTC