Skip to content

Creating a simple object

rasta edited this page Oct 3, 2023 · 19 revisions

Example for phaidra-sandbox.univie.ac.at, and for a picture object. Replace:

  • the URL of your instance.
  • credentials
  • picture/create to eg document/create. Possibilities are: picture, audio, video, document, unknown, collection, container, page

POST https://services.phaidra-sandbox.univie.ac.at/api/picture/create

Param Value
file [upload file via "multipart/form-data"]
metadata See JSON-LD example
mimetype optional: if not provided, heuristics is used on server side

Request example:

curl -X POST -u username:password -F "file=@picture.jpg" -F metadata=@metadata.json https://services.phaidra-sandbox.univie.ac.at/api/picture/create

Response example:

{"alerts":[],"pid":"o:1","status":200}

Possible content models

Content model Content model internal Method
picture cmodel:Picture picture/create
document cmodel:PDFDocument document/create
video cmodel:Video video/create
audio cmodel:Audio audio/create
collection cmodel:Collection collection/create
data cmodel:Asset unknown/create

JSON-LD example:

{
  "metadata": {
    "json-ld": {
      "edm:hasType": [
        {
          "@type": "skos:Concept",
          "skos:exactMatch": [
            "https://pid.phaidra.org/vocabulary/Q4Q5-3554"
          ],
          "skos:prefLabel": [
            {
              "@language": "eng",
              "@value": "postcard"
            }
          ]
        }
      ],
      "dce:title": [
        {
          "@type": "bf:Title",
          "bf:mainTitle": [
            {
              "@value": "Feldpostkarte",
              "@language": "deu"
            }
          ]
        }
      ],
      "role:aut": [
        {
          "@type": "schema:Person",
          "schema:familyName": [
            {
              "@value": "Max"
            }
          ],
          "schema:givenName": [
            {
              "@value": "Mustermann"
            }
          ]
        }
      ],
      "dce:subject": [
        {
          "@type": "skos:Concept",
          "skos:prefLabel": [
            {
              "@value": "war",
              "@language": "eng"
            }
          ]
        },
        {
          "@type": "skos:Concept",
          "skos:prefLabel": [
            {
              "@value": "Krieg",
              "@language": "deu"
            }
          ]
        },
        {
          "@type": "skos:Concept",
          "skos:prefLabel": [
            {
              "@value": "Marine",
              "@language": "deu"
            }
          ]
        }
      ],
      "bf:note" : [
        {
           "skos:prefLabel" : [
              {
                 "@value" : "Eine Feldpostkarte der 1.Marine Division.",
                 "@language" : "deu"
              }
           ],
           "@type" : "bf:Summary"
        }
      ],
      "vra:hasInscription": [
        {
          "@type": "vra:Inscription",
          "skos:prefLabel": [
            {
              "@value": "Briefstempel / Kaiserliche Marine / Divisionsboot D 7",
              "@language": "deu"
            }
          ]
        }
      ],
      "dcterms:language" : [
        "deu"
      ],
      "ebucore:filename": [
        "feldpostkarte.jpg"
      ],
      "ebucore:hasMimeType": [
        "image/jpeg"
      ],
      "edm:rights": [
        "http://rightsstatements.org/vocab/InC/1.0/"
      ]
    }
  }
}

For a description of the metadata format, see Metadata fields

There are other datastreams which can be sent as main metadata (UWMETADATA, MODS) or additional metadata (GEO, ANNOTATIONS, ...), examples of which you can find here.

Additionally, metadata hash can contain:

Order of members

Applicable for container and collection

"membersorder": [ 
    { 
        "member": "member_foo", 
        "pos": "1"
    },
    { 
        "member": "member_bar", 
        "pos": "2"
    }  
]

Access rights definition

This example restricts access to a particular username.

"rights": {
  "username": [
    {
      "value": "username",
      "expires": "2026-08-25T14:31:34Z"
    }
  ]
}

Access can also be restricted to faculties, institutes and groups.

"rights": {
  "department": [
    "A421"
  ],
  "faculty": [
    {
      "expires": "2026-03-18T00:00:00.000Z",
      "value": "A51"
    },
    "A-1"
  ],
  "gruppe": [
    "8096BF32-DE44-11E6-A167-ECEC734D5710"
  ],
  "username": [
    "username1",
    {
      "expires": "2020-03-28T00:00:00.000Z",
      "value": "usernam2"
    }
  ]
}

Owner

The object's ownership will be transferred to ownerid after the object was created. This allows for using another account for the upload itself. The accounts which are allowed to transfer ownership need to be configured in PhaidraAPI.json (contact your Phaidra support if your instance is hosted and you need this feature).

"ownerid": "projectusername"

Clone this wiki locally