zwlayer
zwlayer

Reputation: 1824

How to change request type from GET to POST while using VIRTUOSO sparql service

I'm trying to understand how to change a type of request from GET to POST. Currently, I'm using http://virtuoso.redisbiotech.com:8890/sparql as an endpoint and if I write a query in there, it is sent as a get request and since get request has a limit on url length, it is not fine for me. Therefore I need to change it to POST. Is there anyone who is familiar with Virtuoso and know how to do that? I mean I need to sent POST request from that link to server and query should be inside of body of request. My Virtuoso server runs on an Amazon AWS instance.

Upvotes: 0

Views: 639

Answers (2)

chris
chris

Reputation: 1817

You can issue a POST request on that endpoint, you just need to configure your java code to do so. Here's the default query using curl and POST:

curl -X POST -F "format=text/turtle" -F "query=select distinct ?Concept where {[] a ?Concept} LIMIT 5" http://virtuoso.redisbiotech.com:8890/sparql

Result:

@prefix res: <http://www.w3.org/2005/sparql-results#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
_:_ a res:ResultSet .
_:_ res:resultVariable "Concept" .
@prefix rdf:    <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
_:_ res:solution [
      res:binding [ res:variable "Concept" ; res:value rdf:Property ] ] .
@prefix virtrdf:    <http://www.openlinksw.com/schemas/virtrdf#> .
_:_ res:solution [
      res:binding [ res:variable "Concept" ; res:value virtrdf:QuadMapFormat ] ] .
_:_ res:solution [
      res:binding [ res:variable "Concept" ; res:value virtrdf:QuadStorage ] ] .
_:_ res:solution [
      res:binding [ res:variable "Concept" ; res:value virtrdf:array-of-QuadMap ] ] .
_:_ res:solution [
      res:binding [ res:variable "Concept" ; res:value virtrdf:QuadMap ] ] .

Upvotes: 1

TallTed
TallTed

Reputation: 9434

Having answered your other question on this same interaction, I'm strongly thinking that a step back is needed, as both this question and the other are becoming more clearly elements of an XY Problem.

Solving the issue you're seeing with the SPARQL input form will not necessarily solve the issue you're apparently seeing with Apache Jena, which you've not described. (I trust you have reviewed the Virtuoso Jena Provider's docs.)

I strongly suggest you provide a bigger picture description of what you're trying to accomplish, what your starting point is, and what (if any) tools you are required to use -- e.g., is Apache Jena mandatory?

All that said -- the SPARQL input form built into Virtuoso, which is what is found at your link, has some inherent limitations. It was not built as a do-anything-and-everything tool. All queries entered there are submitted using the GET method, and this form's implementation of that verb has an apparent URI length limit. (The issue you're seeing is not a limitation of the HTTP GET verb, per se.)

I think queries which result in URIs that exceed the form's limit should result in an immediate error to the user, without submitting the truncated query to the SPARQL processor at all, and suggest you raise this on the Virtuoso Users mailing list and/or the Virtuoso GIT project issues.

Upvotes: 1

Related Questions