RDF4J REST API更新返回500,'事务处理错误:java.util.concurrent.ExecutionException:java.lang.NullPointerException'

时间:2017-05-27 06:25:17

标签: python rest api rdf4j

我使用python查询RDF4J的REST API,但我似乎无法按照文档(http://docs.rdf4j.org/rest-api/#_the_rdf4j_server_rest_api

中的描述使其工作

我正在做一个工作正常的select语句,但是当我尝试执行insert语句时,我收到以下错误:

"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

我真的很感激这方面的一些帮助。

1 个答案:

答案 0 :(得分:1)

您可以在@Jeen Broekstra发布的评论部分找到答案:

  

你正在做一个POST的地方   文档说你应该使用PUT:   http://docs.rdf4j.org/rest-api/#_the_update_operation