1

I am getting the following error in trying to INSERT DATA into Fuseki by php script:

405: Bad response, 405: Error 405: HTTP method not allowed: SPARQL Update : use POST Fuseki - version 2.3.1 

i m using sparqllib.php library and i have used the same sparql request in the fuseki control panel and it work!

this is my php script:

      $db = sparql_connect( "http://localhost:3030/riimaOnto/update" );

    if(!$db)
    {
        print sparql_errno() . ": " . sparql_error(). "\n";
        exit;
    }

    $id = "MyData";

    $sparql = "PREFIX onto:<http://www.semanticweb.org/riima/ontologies/#>
    INSERT DATA 
    {
        onto:$id a onto:Article
    }";



    $result = sparql_query($sparql);

    if (!$result)
    {
        print sparql_errno() . ": " . sparql_error(). " \n";
        exit;
    }

so how can i insert data to my ontology ??

  • You may need to turn on updates on fuseki. I think the default settings only turn on query. E.g., see http://stackoverflow.com/questions/21581018/fuseki-1-0-1-sparql-update-returns-404. – Joshua Taylor May 13 '16 at 22:34
  • It looks like update is enabled because the error message is from the update servlet itself. It's complaining the request is GET not POST because (I assume) `sparql_query` is a query request over GET. – AndyS May 14 '16 at 09:12

2 Answers2

1

Update is only support by HTTP POST.

The request was sent with HTTP GET. Change operations should never go via GET (the operation maybe cached, POST are not).

In SPARQL query and update are different languages and protocols.

sparql_query presumably does an HTTP GET with ?query=... URL query string.

You need some kind of sparql_update (I don't know sparqllib.php) which uses HTTP POST with the right MIME type and the update in the body. (HTML Form update also works in Fuseki - it will be ?update=...)

AndyS
  • 16,345
  • 17
  • 21
1

if you are using the Apache Jena Fuseki, you should edit the sparql endpoint which by default is "http://localhost:3030/myDataset/query" by clearing off the 'query' and placing 'update' instead

Sterlingking
  • 190
  • 1
  • 6