【发布时间】:2016-04-05 10:59:44
【问题描述】:
我正在尝试使用 PUT 方法创建一个新对象,并使用 SPARQL 查询添加一些我自己的前缀。但是,正在创建的对象没有添加前缀。它适用于 POST 和 PATCH。 SPARQL 为什么以及是否有其他方法可以与 PUT 方法一起使用并使用用户定义的前缀添加?
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX indexing: <http://fedora.info/definitions/v4/indexing#>
DELETE { }
INSERT {
<> indexing:hasIndexingTransformation "default";
rdf:type indexing:Indexable;
dc:title "title3";
dc:identifier "test:10";
}
WHERE { }
我的意思是insert 子句中指定的所有上述值根本没有添加。
编辑1:
url = 'http://example.com/rest/object1'
payload = """
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX indexing: <http://fedora.info/definitions/v4/indexing#>
PREFIX custom: <http://customnamespaces/custom#/>
DELETE { }
INSERT {
<> indexing:hasIndexingTransformation "default";
rdf:type indexing:Indexable;
dc:title "title1";
custom:objState "Active";
custom:ownerId "Owner1";
dc:identifier "object1";
}
WHERE { }
"""
headers = {
'content-type': "application/sparql-update",
'cache-control': "no-cache"
}
response = requests.request("PUT", url, data=payload, headers=headers, auth=('username','password'))
【问题讨论】:
-
如果没有别的办法,那我需要分两步来做:1.用PUT创建对象2.用PATCH更新对象
-
您能否更明确地说明您是如何调用
POST和PUT的? -
嗨,Scott,我已经在问题中添加了它。
-
错误输出是什么样的?你也试过用完整的 URL 替换 qnames 吗?
-
根本没有错误...像往常一样使用此方法创建对象,但它不包含我在查询中提到的属性。什么是 qnames?
标签: sparql put fedora-commons