You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@marmotta.apache.org by Diego Benna <di...@gmail.com> on 2013/09/03 10:28:42 UTC
Query and webservices
Dear community,
I'm trying the Apache API and Marmot calls to webservice.
{BASE} / SPARQL / select? Query = & output = json
as is normal, he says:
no SPARQL query specified
But how should I write the query? I tried to insert a simple select all
{BASE}/sparql/select?query=SELECT+*+WHERE+{%0D%0A++%3Fs+%3Fp+%3Fo%0D%0A}%0D%0ALIMIT+10&output=json
and I return to the classic 404
HTTP Status 400 -
type Status report
message
description The request sent by the client was syntactically incorrect.
Can you help me please? thanks
Diego Benna
Re: Query and webservices
Posted by Sergio Fernández <wi...@apache.org>.
Hi Diego,
On 03/09/13 10:28, Diego Benna wrote:
> I'm trying the Apache API and Marmot calls to webservice.
>
> {BASE} / SPARQL / select? Query = & output = json
>
> as is normal, he says:
> no SPARQL query specified
>
> But how should I write the query? I tried to insert a simple select all
>
> {BASE}/sparql/select?query=SELECT+*+WHERE+{%0D%0A++%3Fs+%3Fp+%3Fo%0D%0A}%0D%0ALIMIT+10&output=json
>
> and I return to the classic 404
>
> HTTP Status 400 -
> type Status report
> message
> description The request sent by the client was syntactically incorrect.
Looks that your are wrongly encoding the query in your request. But
trying to reproduce the issue, I have detected a bug (MARMOTTA-298) on
the HTML serialization.
http://issues.apache.org/jira/browse/MARMOTTA-298
If you were performing the request through your browser, HTML would be
the format sent.
Please, take intro account that the 'output', 'format' or whatever query
parameters are not part of the standard SPARQL 1.1. Protocol clients
should use HTTP content negotiation [RFC2616] to request response
formats that the client can consume. For further details, please check:
http://www.w3.org/TR/sparql11-protocol/#conneg
Anyway, Marmotta, as many other SPARQL implementation, offers such
non-official parameter for users' convenience. But the value must be a
mimetype , not a simple label. So, instead of 'json', should be
'application/json':
http://localhost:8080/sparql/select?query=SELECT+*+WHERE+%7B%0D%0A++%3Fs+%3Fp+%3Fo%0D%0A%7D%0D%0ALIMIT+10&output=application%2Fjson
That's why in your request 'json' was ignored, and Marmotta tried to
return other format (HTML in that case).
For avoiding such problems, I'd recommend you to use a SPARQL client,
which should implement all those details of the protocol. For instance,
the Marmotta Client Library comes with a SPARQL client implementation;
although any other implementation of the protocol (Jena, Sesame or
whatever) should be fully compatible with Marmotta.
BTW, I already solved MARMOTTA-298 in the source code repository; so
next builds will include the patch. Thanks for reporting the issue.
Kind regards,
--
Sergio Fernández