1

I try to query a marklogic server (version 8) via their sparql endpoint and the sparqlrepository from rdf4j(2.1.4) but the marklogic endpoint seems to not accept these sparql queries.

Code example:

String sparqlEndpoint = "http://url/v1/graphs/sparql";
SPARQLRepository repo = new SPARQLRepository(sparqlEndpoint);
repo.initialize();
repo.getConnection().hasStatement(null, null, null, false);

This leads to the following error:

"errorResponse":{"statusCode":400, "status":"Bad Request", "messageCode":"REST-UNSUPPORTEDPARAM", "message":"REST-UNSUPPORTEDPARAM: (err:FOER0000) Endpoint does not support query parameter: invalid parameters: queryLn, infer for request"}}

Any suggestions?

ChristophE
  • 760
  • 1
  • 9
  • 21

2 Answers2

4

MarkLogic does not accept the parameter called queryLn (Query language).

The languages are SARQL and StructuredQueries and use different parameters to pass the two languages.

Please refer to the documentation here: https://docs.marklogic.com/REST/GET/v1/graphs/sparql

I suggest you find a way to suppress the queryLn parameter in your code making the call..

  • Issue logged as a bug in RDF4J: https://github.com/eclipse/rdf4j/issues/721 . Arguably MarkLogic could be a bit more lenient and simply ignore the parameter, though :) – Jeen Broekstra Jan 13 '17 at 22:56
  • 1
    Is the base answer acceptable and complete for the scope of the question? If so, please mark it as so so that we keep Stack Overflow clean. Its dangerous for a any system to ignore unknown parameters that the caller thinks are necessary. It makes more sense to me that a connecting system would adhere to the API as documented. Rather than ignore parameters, MarkLogic could consider queryLn an "optional" parameter where there is only one valid value (SPARQL). That is quite different than allowing a client to connect to an API and think it is sending useful parameters that are just ignored. – David Ennis -CleverLlamas.com Jan 14 '17 at 09:11
  • `queryLn` is a parameter that is specific to RDF4J's own REST API. It's not a matter of the client mistakenly thinking that that is something MarkLogic's API will understand, it's simply some redundant info that gets included for RDF4J-based servers but has no meaning in the standard SPARQL protocol. Logging a warning is sensible, but there's no reason to completely fail the request: the server receives sufficient info to honor the request (and as far as I know there's no requirement in SPARQL protocol that _only_ the documented parameters are sent). – Jeen Broekstra Jan 15 '17 at 01:29
1

As explained in the answer by David Ennis, the problem is that RDF4J's SPARQL endpoint client sends several parameters in its requests that are not part of the W3C SPARQL 1.1 Protocol; they are part of the RDF4J REST API (an extension of the SPARQL Protocol) instead.

While most SPARQL endpoint implementations simply ignore parameters that are not part of the standard (or log a warning), MarkLogic implements a stricter policy and just flat out refuses to answer such requests.

A solution in your case is to upgrade to RDF4J 2.2. Improvement #721, which is about making sure that only standards-compliant parameters are sent to non-RDF4J SPARQL endpoints, was implemented in this new release, and (assuming MarkLogic is otherwise standards-compliant) this should fix the problem in communicating with your MarkLogic endpoint.

Jeen Broekstra
  • 21,642
  • 4
  • 51
  • 73