SPARQL UPDATE - General Questions

Hello! I want to insert something in a dataset in my pod using a sparql update query. According to this it should be possible:

But after reading different posts, my understanding is that its not possible after all as not all servers support it? (
Can someone confirm this?

I also tried using store.query() in rdflib.js. Is it possible to insert data on store through queries, or is store.add() the only option?

I really want to update the dataset through a query, is this possible at all? Either clientside or remotely?

Yes, SPARQL patches do work. You can use rdflib’s updater which uses rdflib statement objects, or you can use Solid File Client’s patch method. The docs for Solid-File-Client show the basic syntax of two different kinds of patches - ‘text/n3’ or 'application/sparql. You could also use those examples with straight fetches with only an auth library and without Solid-File-Client.

The text/n3 form of patch is more flexible and will be the format of patch that is standardized in the Solid spec.

Both forms of patch work on NSS. If you try them on other platforms, you might report back here.

1 Like

If you only want to work on Store, with rdflib.js have you looked at store.remove() and store.applyPatch()

1 Like

Thank you for the reply. So i tried sending a patch through the session fetch, but then i get an 415 error that says ‘Unsupported Media Type’. I also tried it with content type ‘text/turtle’ and ‘text/n3’.

Example of my code:
const myQuery = ‘INSERT { <#> <#> ‘some value’ . } WHERE { ?s ?p ?o . }’

const saveLocation = ’url of dataset in pod’

await session.fetch(saveLocation, { method: ‘PATCH’, headers: new Headers({ ‘Content-Type’: ‘application/sparql-update’ }), body: myQuery })

Does this look ok or am I missing something obvious ?

Thank you for the reply. I might want to work on the store yes! But i need to be able to update the dataset/store through sparql update.
For example: const myQuery = ‘INSERT { <#> <#> ‘some value’ . } WHERE { ?s ?p ?o . }’

I read that the store.applyPatch() is expecting an array of Statement Objects. I could not find a way to convert my query into a Statement…

Do you know if this is possible to achieve with my requirement ?

Your body is not correct. You can look at GitHub - jeff-zucker/solid-file-client: A Javascript library for creating and managing files and folders in Solid data stores

There are 2 body examples.

Ok, so a patch with content-type: ‘application/sparql-update’ does not support the WHERE keyword.
Then it should work if i exclude it right ?

Something like :
const myQuery = ‘INSERT { ‘something’ .}.’

Don’t forgive the <>. But may be they just don’t show

1 Like

Yes they are included! And i finally got it working. The way i had defined the header as a ‘new header’ was breaking the request. Thank you!


I have another question regarding the limited SPARQL support in Solid Pods:
The ‘Solid HTTP REST API Spec’ that I linked to earlier, also mention support for SELECT queries encoded in the url.

However according to this issue on (GitHub Support SPARQL GET requests as documented on solid-spec · Issue #962 · solid/node-solid-server · GitHub) from 2018, they say it was never implemented (on NSS atleast) and is now removed from the spec.

Is this still true for NSS and are there other solid servers that actually support this ?

No NSS does not support SPARQL SELECT. CSS has a SPARQL endpoint option. Client-side SPARQL queries can be done against Solid Servers including with authenticated fetch using either rdflib or comunica.