Omeka S - create vocabulary with REST API

Hi all,
I am trying to automate things with Omeka S installations and am attempting to create or import a vocabulary with the REST API, but for some reason that only partly works: which means: a new vocabulary record get’s created, but the imported classes and properties are zero (0).
Is it not possible to import a vocabulary this way? Or could someone maybe explain how to do this?

I attempted this curl call:

curl -X POST \
      -H "Content-Type: application/json" \
      -H "Accept: application/json" \
      --data '{"o:prefix":"skos", "o:label":"SKOS", "format":"rdfxml", "o:namespace_uri":"http://www.w3.org/2004/02/skos/core#","o:import_from_uri":"http://www.w3.org/TR/skos-reference/skos.rdf"}' \
      'http://localhost:8095/api/vocabularies?key_identity=secret&key_credential=also_secret'

Any help on this is greatly appreciated!
Petra

BTW: I think I also noticed that when using the UI to import a vocabulary with a remote_url it almost always fails when attempting to autodetect the format. Does anyone else have the same experience?

Hi Petra,

I have no experience with this particular REST method. But maybe the following might be usefull: the Omeka-CLI by GhentCDH has the vocabulary:create-import-config option which make a data file which looks like:

{
    "url": "https://schema.org/version/latest/schemaorg-current-https.rdf",
    "label": "schema",
    "namespaceUri": "https://schema.org/",
    "prefix": "schema",
    "format": "auto"
}

So I do spot some differences with your data string?
And maybe Omeka-CLI might be the tool you’re looking for.

Hi Bob,

Thanks for that suggestion I did not yet know about that tool. Unfortunately it seems to only work on a local installation of Omeka S using the PHP interface and not via the REST API, which is what I was aiming for.
Seems like a useful tool for other things though :wink:

Regards,
Petra

Hi Petra,

looking at the Omeka S code, the REST API does not use the RdfImporter when creating a vocabulary, it just creates an new vocabulary entry with empty classes and properties.

Best,
Frederic

Yeah, I meant to reply to this at some point to this effect:

The RDF importer isn’t hooked up to the REST API. You can create a vocabulary and its classes and properties by POSTing to the vocabularies endpoint, but it’s expecting a structure like

{
    "o:namespace_uri": "http://www.w3.org/2004/02/skos/core#",
    "o:prefix": "skos",
    "o:label": "SKOS",
    "o:comment": "Vocab comment",
    "o:class": [
        {
            "o:local_name": "SomeClass",
            "o:comment": "Comment/description of class",
            "o:label": "Label for class"
        }
    ],
    "o:property": [
        {
            "o:local_name": "someProperty",
            "o:comment": "Comment/description of property",
            "o:label": "Label for property"
        }
    ]
}

There isn’t something you can pass to the vocabulary endpoint to make it read from a vocab file the way the import option in the interface does. It’s something we could provide without too much trouble though if there’s interest… probably with a different endpoint, I’d imagine.