On 22/06/2022 05:24, Noah from ProvocaTeach wrote:
The standard way to talk to RDF databases (such as Fuseki) is with a language called 
SPARQL: "SPARQL Protocol And RDF Query Language". It is the SQL of RDF land.

There are many great resources for learning SPARQL, but you can hardly do 
better than the spec itself: https://www.w3.org/TR/sparql11-query/ (Be aware: 
SPARQL Query is for reading only; SPARQL Update is for modifying.)

If you don't want to learn SPARQL, there is also a Graph Store Protocol which 
lets you communicate more naturally via POST, GET, etc. but is less powerful.

You need to decide if you want to:

(1) make a SPARQL Update (which works without much configuration, but requires 
knowledge of SPARQL); or

(2) use the Graph Store Protocol (which I think requires some configuration on 
Fuseki, but lets you post the file directly).

You must also set the Content-Type header on your HTTP request to "application/sparql-update" for SPARQL 
updates; "application/sparql-query" for SPARQL queries; or the appropriate RDF type ("text/turtle", 
"application/trig", etc.) for the Graph Store Protocol. If you need a refresher on HTTP headers, see this MDN 
page: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers

Other useful links:

SPARQL 1.1 Protocol: https://www.w3.org/TR/sparql11-protocol/

Graph Store Protocol:
https://www.w3.org/TR/sparql11-http-rdf-update/

Good background.


On Tue, Jun 21, 2022, at 21:00, Dương Hồ wrote:
Hi all,
I am trying send axios.post update from ReactJS to Fuseki.

axios.post('http://127.0.0.1:3030/myDataset/update', file)
The file is a owl file save from protege.
but this have an error with status code : 415 Unsupported Media Type.
Must be application/sparql-update or application/x-www-form-urlencoded (got
application/json)

Are you trying to perform a SPARQL update? Or upload a data file?

It looks like the file is being sent "application/json", possibly the default from Axios.

You have to get axios to set the Content-Type with an extra "headers" object argument to .post.

For SPARQL update: "application/sparql-update"

For uploading a data file, the URL is either 'http://127.0.0.1:3030/myDataset/' or 'http://127.0.0.1:3030/myDataset/data'.

If the file is JSON-LD, you should use "Content-Type: application/ld+json".

Operations on the dataset URL ('http://127.0.0.1:3030/myDataset/') look at the Conetnt-Type to decide what operation is being performed

If you run Fuseki with verbose mode ("-v") it prints out HTTP headers in and headers out.

    Andy




Can you help me how to update and query in Fuseki?


Reply via email to