我有一个本地本体,我想用 SPARQL 进行查询。我使用的是 JavaScript,因此我设置了一个 Comunica 查询引擎,并使用
comunica-sparql-file-http
util 打开了一个 SPARQL 端点。 SELECT
查询按预期工作并返回我期望它们返回的内容。但是,我在更新查询方面运气不佳,具体来说,INSERT DATA
。端点返回 [400] 错误请求。
要求如下:
fetch('http://localhost:3000/sparql', {
method: 'post',
headers: new Headers({
'Content-Type': 'application/sparql-update'
}),
body: query
})
.then(response => response.text())
.then(response => {
console.log(response);
params.res.send(!!response.ok);
})
.catch(err => {
console.error(err);
params.res.send(false);
});
端点响应的文本输出如下:
urn:comunica:default:rdf-update-hypermedia/mediators#main mediated over all rejecting actors:
Actor urn:comunica:default:rdf-update-hypermedia/actors#patch-sparql-update could not detect a destination with 'application/sparql-update' as 'Accept-Patch' header.
Actor urn:comunica:default:rdf-update-hypermedia/actors#put-ldp could not detect a destination with 'Allow: PUT' header.
Actor urn:comunica:default:rdf-update-hypermedia/actors#sparql could not detect a SPARQL service description or URL ending on /sparql or /update.
端点似乎处于只读模式,不允许我更新本体,但我在初始化端点时添加了
-u
,在此之前,错误消息明确指出“尝试写入处于只读模式”。
我尝试过:
query()
的queryVoid()
和queryEngine
方法代替fetch
;两者都产生了Error: Unknown entry type: update
body: { update: query }
和 body: { query }
。只有 body: query
不会产生解析错误。初始化端点时我是否需要使用另一个标志,或者我需要更改一些配置?
您的问题有办法解决吗?我也面临同样的情况