0
我使用python來查詢RDF4J的REST API,但我似乎無法得到它如文檔中描述的工作(http://docs.rdf4j.org/rest-api/#_the_rdf4j_server_rest_api)RDF4J REST API更新返回500,'事務處理錯誤:java.util.concurrent.ExecutionException:java.lang.NullPointerException'
我做這工作正常,但當我嘗試做一個INSERT語句,我得到以下錯誤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
我真的很感激一些這方面的幫助。
不知道這解決了你的錯誤,但你正在做一個帖子裏的文檔說,你應該使用PUT:HTTP ://docs.rdf4j.org/rest-api/#_the_update_operation –
是的,就是那個。使用錯誤的請求。謝謝@JeenBroekstra –