RDF4J REST API update returning 500, 'Transaction handling error: java.util.concurrent.ExecutionException: java.lang.NullPointerException'
RDF4J REST API update returning 500, 'Transaction handling error: java.util.concurrent.ExecutionException: java.lang.NullPointerException'
我正在使用 python 查询 RDF4J 的 REST API,但我似乎无法按照文档中的描述使其工作 (http://docs.rdf4j.org/rest-api/#_the_rdf4j_server_rest_api)
我正在做一个 select 语句,它工作正常,但是当我尝试做一个插入语句时,我收到以下错误:
"500, 'Transaction handling error: java.util.concurrent.ExecutionException: java.lang.NullPointerException'"
为了执行 POST 请求,我生成了一个事务 ID,然后执行实际的 POST 请求:
# Generate tranzaction ID
transaction_id = requests.post('http://localhost:8080/rdf4j-server/repositories/ProiectICVG/transactions')enter code here
transaction_id = transaction_id.headers['Location']
transaction_id = string.split(transaction_id, '/')
transaction_id = transaction_id[-1]
#Make the post request
return_data = requests.post('http://localhost:8080/rdf4j-server/repositories/ProiectICVG/transactions/'+transaction_id+'?action=UPDATE',
data={'Host': 'localhost',
'Content-Type': 'application/sparql-query',
'query': 'PREFIX : <http://proj.local#>\
insert data {\
graph :isIncidentGraph{\
:INC005 :hasTtile "test".}'
})
print(return_data.status_code, return_data.content)
输出如下:
"C:\Python27\python.exe D:/xamp/cgi-bin/index.py
(500, 'Transaction handling error: java.util.concurrent.ExecutionException: java.lang.NullPointerException')
Process finished with exit code 0
我真的很感激在这方面的帮助。
您可以在@Jeen Broekstra 发表的评论部分找到答案:
You're doing a POST where the
documentation says you should be using PUT:
http://docs.rdf4j.org/rest-api/#_the_update_operation
我正在使用 python 查询 RDF4J 的 REST API,但我似乎无法按照文档中的描述使其工作 (http://docs.rdf4j.org/rest-api/#_the_rdf4j_server_rest_api)
我正在做一个 select 语句,它工作正常,但是当我尝试做一个插入语句时,我收到以下错误:
"500, 'Transaction handling error: java.util.concurrent.ExecutionException: java.lang.NullPointerException'"
为了执行 POST 请求,我生成了一个事务 ID,然后执行实际的 POST 请求:
# Generate tranzaction ID
transaction_id = requests.post('http://localhost:8080/rdf4j-server/repositories/ProiectICVG/transactions')enter code here
transaction_id = transaction_id.headers['Location']
transaction_id = string.split(transaction_id, '/')
transaction_id = transaction_id[-1]
#Make the post request
return_data = requests.post('http://localhost:8080/rdf4j-server/repositories/ProiectICVG/transactions/'+transaction_id+'?action=UPDATE',
data={'Host': 'localhost',
'Content-Type': 'application/sparql-query',
'query': 'PREFIX : <http://proj.local#>\
insert data {\
graph :isIncidentGraph{\
:INC005 :hasTtile "test".}'
})
print(return_data.status_code, return_data.content)
输出如下:
"C:\Python27\python.exe D:/xamp/cgi-bin/index.py
(500, 'Transaction handling error: java.util.concurrent.ExecutionException: java.lang.NullPointerException')
Process finished with exit code 0
我真的很感激在这方面的帮助。
您可以在@Jeen Broekstra 发表的评论部分找到答案:
You're doing a POST where the documentation says you should be using PUT: http://docs.rdf4j.org/rest-api/#_the_update_operation