1

I have an RDF-file stored on my server. The file or at least the file-content should be uploaded to a remote GrapbDB over API.

On the documentation there are two ways to do this. The first one is uploading it to server files and then loading it to GraphDB. Here the problem is, that I am not the owner of the server, GraphDB is running. So I can`t upload it to server files. Or is there maybe another API for that?

The other way is providing a public API on my server and then trigger GraphDB to download the file from my server. But my API must be protected with credantials or JWT. But I don´t know how to set the credantials in the API-Call.

Isn`t there a way to upload a simple graph to a repository?

Gigalodon
  • 51
  • 1
  • 8

1 Answers1

3

There is a browser-based user interface in GraphDB that allows you to import from local files. If this is allowed on the server you are connecting to, and you only need to do this once then I think this would be the quickest route to go.

If you want to upload a local file to GraphDB using dotNetRDF, then I would advise you to use the SPARQL 1.1 graph store protocol API via the VDS.RDF.Storage.SparqlHttpProtocolConnector as described here. The base URL you need to use will depend on the configuration of the server and possibly also on the version of GraphDB that it is running, but for the latest version (9.4) the pattern is: <RDF4J_URL>/repositories/<repo_id>/rdf-graphs/service

The connector supports HTTP Basic Authentication (which is one of the options offered by GraphDB) so if you have a user name and password you could try the SetCredentials method on the connector to specify those credentals and if necessary force the use of HTTP Basic Authentication by setting the global options property VDS.RDF.Options.ForceHttpBasicAuth to true.

Kal
  • 1,887
  • 12
  • 16
  • The connector could be the solution. But it returns that I am unauthorized. Could it bee, that this is just possible for "repository managers" and not for "users"? – Gigalodon Sep 03 '20 at 17:55
  • Yes, that is definitely possible. The connector does support HTTP Basic Authentication so if you have a user name and password you could try the `SetCredentials` method on the connector to specify those credentals and see if that works. – Kal Sep 04 '20 at 14:55
  • 1
    I forgot to Add Options.ForceHttpBasicAuth = true . When working with default Graph it is now working. But when when using a exisiting or a new Graph no Triples will be added to store. E. g. con.UpdateGraph(new Uri("urn:test"), g.Triples, null); does not work – Gigalodon Sep 07 '20 at 12:49
  • Thats a bit odd. According to the GraphDB docs, the `/rdf-graphs/service` endpoint should support updating a graph by passing the `graph` query parameter, which is what the connector does. It might be helpful if you enable full HTTP debugging in dotNetRDF so that you can get a trace output showing exactly what the server response is. See https://github.com/dotnetrdf/dotnetrdf/wiki/HowTo-Debug-HTTP-Communication for details on how to do this. – Kal Sep 08 '20 at 13:35
  • This seems to be a Problem with GraphDB 8.8 documentation. According to documentation you should use another URL than rdf-graphs/service. Now I just changed it and it is working. – Gigalodon Sep 11 '20 at 07:30
  • Glad this is resolved. Just a note: you can do this simply with curl, don't need `SparqlHttpProtocolConnector` – Vladimir Alexiev Sep 18 '20 at 07:29