Search code examples
pythonrestapirdf4j

RDF4J REST API update returning 500, 'Transaction handling error: java.util.concurrent.ExecutionException: java.lang.NullPointerException'


I'm using python to query the REST API of RDF4J but I can't seem to get it work as described in the documentation (http://docs.rdf4j.org/rest-api/#_the_rdf4j_server_rest_api)

I'm doing a select statement which works fine but when I try to do an insert statement i get the following error:

"500, 'Transaction handling error: java.util.concurrent.ExecutionException: java.lang.NullPointerException'"

To do a POST request I generate a transaction ID and then do the actual POST request :

# 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)

The output is the following :

"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

I would really appreciate some help on this.


Solution

  • You can find the answer in the comments section posted by @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