Explain over http - keep getting 500 - what am I doing wrong?

Hi,

I’m trying to do a query explain over http, but I keep getting 500 back. From what I read in the docs, the following should work:

curl -X POST \
  http://localhost:5820/inf3580/explain \
  -H 'accept: text/plain' \
  -H 'authorization: Basic YWRtaW46YWRtaW4=' \
  -H 'cache-control: no-cache' \
  -H 'content-type: text/plain' \
  -d 'select * where { ?a ?b ?c }'

This gives me 500 back with the following message: There was a fatal error on the server

In stardog.log I see this error:

ERROR 2017-04-23 10:44:23,241 [Stardog.Executor-87] com.complexible.common.protocols.server.rpc.ServerHandler:exceptionCaught(401): exceptionCaughtServerHandler
java.lang.NullPointerException
ERROR 2017-04-23 10:44:23,244 [StardogServer.WorkerGroup-7] com.complexible.stardog.protocols.http.server.HttpMessageEncoder:createErrorResponse(293): The result encoder received an error message it could not encode, error was:
java.lang.NullPointerException

Cheers,
Håvard

Hi Håvard,

Our docs (and especially the apiary.io HTTP API docs) are sometimes unclear as to what the server is expecting. We are hoping to have that cleaned up for the 5.x release cycle.

Your command is very close, however the server is expecting application/x-www-form-urlencoded content, with the body consisting of url-encoded key/value pairs. So a working version of your command would be as follows:

curl -X POST \
  http://localhost:5820/inf3580/explain \
  -H 'accept: text/plain' \
  -H 'authorization: Basic YWRtaW46YWRtaW4=' \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/x-www-form-urlencoded' \
  -d 'query=select%20*%20where%20%7B%20%3Fa%20%3Fb%20%3Fc%20%7D'

Edited to add: You can also get the same results via a GET query:

curl -X GET \
  'http://localhost:5820/inf3580/explain?query=select%20*%20where%20%7B%20%3Fa%20%3Fb%20%3Fc%20%7D' \
  -H 'accept: text/plain' \
  -H 'authorization: Basic YWRtaW46YWRtaW4=' \
  -H 'cache-control: no-cache'

That worked great, thanks Stephen :slight_smile:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.