I was following this package tutorial for connecting to GraphDB. It worked. But then, I am now running the same code on a different PC and I get 403 Error... I don't understand why it used to work on one pc and now not on the other one? In the end, I use the graphDBEndpoint module to use it for the query.js.
This is my code:
const { EnapsoGraphDBClient } = require("@innotrade/enapso-graphdb-client");
const { EnapsoGraphDBAdmin } = require("@innotrade/enapso-graphdb-admin");
// connection data to the running GraphDB instance
const GRAPHDB_BASE_URL = "http://127.0.0.1:7200",
GRAPHDB_REPOSITORY = "Test",
GRAPHDB_USERNAME = "Test",
GRAPHDB_PASSWORD = "Test",
GRAPHDB_CONTEXT_TEST = "http://ont.enapso.com/repo",
GRAPHDB_CONTEXT_SHACL = "http://rdf4j.org/schema/rdf4j#SHACLShapeGraph";
const DEFAULT_PREFIXES = [
EnapsoGraphDBClient.PREFIX_OWL,
EnapsoGraphDBClient.PREFIX_RDF,
EnapsoGraphDBClient.PREFIX_RDFS,
EnapsoGraphDBClient.PREFIX_XSD,
EnapsoGraphDBClient.PREFIX_PROTONS,
{
prefix: "entest",
iri: "http://ont.enapso.com/test#",
},
];
let graphDBEndpoint = new EnapsoGraphDBClient.Endpoint({
baseURL: GRAPHDB_BASE_URL,
repository: GRAPHDB_REPOSITORY,
prefixes: DEFAULT_PREFIXES,
transform: "toJSON",
});
graphDBEndpoint
.login(GRAPHDB_USERNAME, GRAPHDB_PASSWORD)
.then((result) => {
console.log(result);
})
.catch((err) => {
console.log(err);
});
exports.uploadFiletoGraphDB = (filePath) => {
graphDBEndpoint
.uploadFromFile({
filename: `./${filePath}`,
format: "application/rdf+xml",
baseIRI: "http://ont.enapso.com/test#",
context: "http://ont.enapso.com/test",
})
.then((result) => {
console.log(result);
})
.catch((err) => {
console.log(err, "process error here...");
});
};
exports.getQuery = async (queryString) => {
return new Promise(function (resolve, reject) {
graphDBEndpoint
.query(queryString, {
transform: "toJSON",
})
.then((result) => {
resolve(result);
})
.catch((err) => {
reject(err);
});
});
};
exports.GRAPHDB_CONTEXT_TEST = GRAPHDB_CONTEXT_TEST;
exports.module = graphDBEndpoint;```