Skip to content
Anusha Ranganathan edited this page Dec 4, 2018 · 38 revisions

Sword V2 end points serviced by the willow_sword engine

Integrator: Hyrax V2

Reference: Sword v2 profile

SUMMARY

Sword engine supports the following:

  • POST, PUT and GET to create, edit and view a work
  • POST, PUT and GET to create, edit and view a file set
  • The metadata and payload can be sent either as a binary data or as multipart form data.
  • The payload can be
    • any file
    • a number of files in a zip
    • or a number of files in a zip, organized in a bag.
  • When updating a file set, if there are multiple files, one is picked
  • If the metadata file (metadata.xml) is sent withthe form and in the zipped payload,
    • The metadata sent with the form data is used over that found in the zip file
    • The metadata included in the bag is used and the form metadata is ignored

Contents

  1. Get service document
  2. Get collection
  3. Add new work: metadata only
    1. Add new work: metadata only (binary)
    2. Add new work: Metadata only (form-data)
  4. Add new work: zip file with metadata and file
    1. Add new work: zip file with metadata and file (binary)
    2. Add new work: metadata and zip payload (form-data)
    3. Add new work: zip payload with file and metadata (form-data)
  5. Add new work: Metadata and file in bagit zip file
    1. Add new work: Metadata and file in bagit zip file (binary)
    2. Add new work: payload containing metadata and file in bagit zip (form-data)
  6. Get work with only metadata
  7. Get work with file and metadata
  8. Get work that doesn't exist
  9. Get file metadata
  10. Add file to existing work (binary)
  11. Update file metadata (binary)
  12. Authorizing sword requests
  13. Update work

Sword Calls

  1. Get service document

    METHOD

    GET
    

    ENDPOINT

    /sword/service_document
    Example: https://hyrax.digitalnest.co.uk/sword/service_document
    

    HEADERS

    Content-Type: application/xml
    

    BODY

    CURL REQUEST

    curl --request GET \
      --url https://hyrax.digitalnest.co.uk/sword/service_document \
      --header 'Content-Type: application/xml'
    

    EXAMPLE RESPONSE

    200 OK
    
    <service xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:sword="http://purl.org/net/sword/terms/" xmlns="http://www.w3.org/2007/app">
        <sword:version>2.0</sword:version>
        <workspace collections="1">
            <atom:title>Hyrax Sword V2 server</atom:title>
            <collection href="http://hyrax.digitalnest.co.uk/sword/collections/default">
                <atom:title>Default collection</atom:title>
                <accept>*/*</accept>
                <accept alternate="multipart-related">*/*</accept>
                <sword:collectionPolicy>TODO: Collection Policy</sword:collectionPolicy>
                <dcterms:abstract></dcterms:abstract>
                <sword:mediation>true</sword:mediation>
                <sword:treatment>TODO: Treatment description</sword:treatment>
                <sword:acceptPackaging>http://purl.org/net/sword/package/SimpleZip</sword:acceptPackaging>
                <sword:acceptPackaging>http://purl.org/net/sword/package/BagIt</sword:acceptPackaging>
                <sword:acceptPackaging>http://purl.org/net/sword/package/Binary</sword:acceptPackaging>
            </collection>
        </workspace>
    </service>
    

  2. Get collection

    METHOD

    GET
    

    ENDPOINT

    /sword/collections/[collection_id] 
    Example: https://hyrax.digitalnest.co.uk/sword/collections/default
    

    Note
    If not supporting collections use default as id
    HEADERS

    Content-Type: application/xml
    

    BODY

    CURL REQUEST

    curl --request GET \
      --url https://hyrax.digitalnest.co.uk/sword/collections/default \
      --header 'Content-Type: application/xml'
    

    EXAMPLE RESPONSE

    200 OK
    
    <feed xmlns="http://www.w3.org/2005/Atom">
      <title>Default collection</title>
      <link rel="edit" href="http://hyrax.digitalnest.co.uk/sword/collections/default/works"/>
      <entry>
        <content rel="src" href="http://hyrax.digitalnest.co.uk/sword/collections/default/works/dn39x152w"/>
        <link rel="edit" href="http://hyrax.digitalnest.co.uk/sword/collections/default/works/dn39x152w/file_sets"/>
      </entry>
      <entry>
        <content rel="src" href="http://hyrax.digitalnest.co.uk/sword/collections/default/works/1g05fb60f"/>
        <link rel="edit" href="http://hyrax.digitalnest.co.uk/sword/collections/default/works/1g05fb60f/file_sets"/>
      </entry>
      <entry>
        <content rel="src" href="http://hyrax.digitalnest.co.uk/sword/collections/default/works/jh343s28d"/>
        <link rel="edit" href="http://hyrax.digitalnest.co.uk/sword/collections/default/works/jh343s28d/file_sets"/>
      </entry>
      <entry>
        <content rel="src" href="http://hyrax.digitalnest.co.uk/sword/collections/default/works/z316q156s"/>
        <link rel="edit" href="http://hyrax.digitalnest.co.uk/sword/collections/default/works/z316q156s/file_sets"/>
      </entry>
      <entry>
        <content rel="src" href="http://hyrax.digitalnest.co.uk/sword/collections/default/works/44558d285"/>
        <link rel="edit" href="http://hyrax.digitalnest.co.uk/sword/collections/default/works/44558d285/file_sets"/>
      </entry>
    </feed>
    

  3. Add New work: metadata only

    1. Add new work: Metadata only (binary)

      METHOD

      POST binary data
      

      ENDPOINT

      /sword/collections/[collection_id]/works
      Example: https://hyrax.digitalnest.co.uk/sword/collections/default/works
      

      NOTE
      The collection need not exist. The work is not added to the collection. No check is done to the collection id.

      HEADERS
      Must include the Content-Disposition header with the filename metadata.xml

      Content-Type: application/xml
      Packaging: application/atom+xml;type=entry
      In-Progress: false
      On-Behalf-Of: hyrax@testinstance
      Content-Disposition: attachment; filename=metadata.xml
      

      BODY
      binary file dc.xml

      CURL REQUEST

      curl --request POST \
        --url https://hyrax.digitalnest.co.uk/sword/collections/default/works \
        --header 'Content-Disposition: attachment; filename=metadata.xml' \
        --header 'Content-Type: application/xml' \
        --header 'In-Progress: false' \
        --header 'On-Behalf-Of: hyrax@testinstance' \
        --header 'Packaging: application/atom+xml;type=entry' \
        --data-binary @dc.xml
      

      EXAMPLE RESPONSE

      201 Created
      
      <feed xmlns="http://www.w3.org/2005/Atom">
        <title>Title, Test record with only metadata</title>
        <content rel="src" href="http://hyrax.digitalnest.co.uk/sword/collections/default/works/jm214p12r"/>
        <link rel="edit" href="http://hyrax.digitalnest.co.uk/sword/collections/default/works/jm214p12r/file_sets"/>
      </feed>
      

    2. Add new work: Metadata only (form-data)

      METHOD

      POST multi-part form data
      

      ENDPOINT

      /sword/collections/[collection_id]/works
      Example: https://hyrax.digitalnest.co.uk/sword/collections/default/works
      

      NOTE
      The collection need not exist. The work is not added to the collection. No check is done to the collection id.

      HEADERS

      In-Progress: false
      On-Behalf-Of: hyrax@testinstance
      

      FIELDS
      Field name: metadata
      Field value: file dc.xml or xml data as string

      CURL REQUEST

      curl --request POST \
        --url https://hyrax.digitalnest.co.uk/sword/collections/default/works \
        --header 'In-Progress: false' \
        --header 'On-Behalf-Of: hyrax@testinstance' \
        -F metadata=@dc.xml
      

      EXAMPLE RESPONSE

      201 Created
      
      <feed xmlns="http://www.w3.org/2005/Atom">
        <title>Test record with only metadata</title>
        <content rel="src" href="http://hyrax.digitalnest.co.uk/sword/collections/default/works/ft848q60n"/>
        <link rel="edit" href="http://hyrax.digitalnest.co.uk/sword/collections/default/works/ft848q60n/file_sets"/>
      </feed>
      
  4. Add new work: Zip file with metadata and file

    1. Add new work: Zip file with metadata and file (binary)

      METHOD

      POST binary data
      

      ENDPOINT

      /sword/collections/[collection_id]/works
      Example: https://hyrax.digitalnest.co.uk/sword/collections/default/works
      

      HEADERS
      Must include the Content-Disposition header with the filename containing the extension .zip

      Content-Type: application/zip
      Packaging: http://purl.org/net/sword/package/BagIt
      In-Progress: false
      On-Behalf-Of: hyrax@testinstance
      Content-Disposition: attachment; filename=testPackage.zip
      

      BODY
      binary file testpackage.zip.

      NOTE
      The zip file should contain a metadata file called metadata.xml

      CURL REQUEST

      curl --request POST \
        --url https://hyrax.digitalnest.co.uk/sword/collections/default/works/ \
        --header 'Content-Disposition: attachment; filename=testPackage.zip' \
        --header 'Content-Type: application/zip' \
        --header 'In-Progress: false' \
        --header 'On-Behalf-Of: hyrax@testinstance' \
        --header 'Packaging: http://purl.org/net/sword/package/BagIt' \
        --data-binary @testPackage.zip
      
      

      EXAMPLE RESPONSE

      201 Created
      
      <feed xmlns="http://www.w3.org/2005/Atom">
        <title>Test record 3</title>
        <content rel="src" href="http://hyrax.digitalnest.co.uk/sword/collections/default/works/2z10wq20d"/>
        <link rel="edit" href="http://hyrax.digitalnest.co.uk/sword/collections/default/works/2z10wq20d/file_sets"/>
      </feed>
      

    2. Add new work: metadata and zip payload (form-data)

      METHOD

      POST multi-part form data
      

      ENDPOINT

      /sword/collections/[collection_id]/works
      Example: https://hyrax.digitalnest.co.uk/sword/collections/default/works
      

      HEADERS

      In-Progress: false
      On-Behalf-Of: hyrax@testinstance
      

      FIELDS
      Field name: metadata
      Field value: file metadata.xml or xml data as string

      Field name: payload
      Field value: file testpackage.zip.

      NOTE
      If the zip file contains a metadata file called metadata.xml, it will overwrite the metadata sent with the form.

      CURL REQUEST

      curl --request POST \
        --url https://hyrax.digitalnest.co.uk/sword/collections/default/works/ \
        --header 'In-Progress: false' \
        --header 'On-Behalf-Of: hyrax@testinstance' \
        -F metadata=@testPackage2b/metadata.xml \
        -F payload=@testPackage2b.zip
      
      

      EXAMPLE RESPONSE

      201 Created
      
      <feed xmlns="http://www.w3.org/2005/Atom">
        <title>Test record 2b</title>
        <content rel="src" href="http://hyrax.digitalnest.co.uk/sword/collections/default/works/8336h188j"/>
        <link rel="edit" href="http://hyrax.digitalnest.co.uk/sword/collections/default/works/8336h188j/file_sets"/>
      </feed>
      

    3. Add new work: zip payload with file and metadata (form-data)

      METHOD

      POST multi-part form data
      

      ENDPOINT

      /sword/collections/[collection_id]/works
      Example: https://hyrax.digitalnest.co.uk/sword/collections/default/works
      

      HEADERS

      In-Progress: false
      On-Behalf-Of: hyrax@testinstance
      

      FIELDS
      Field name: payload
      Field value: file testpackage.zip.

      NOTE
      The zip file should contain a metadata file called metadata.xml

      CURL REQUEST

      curl --request POST \
        --url https://hyrax.digitalnest.co.uk/sword/collections/default/works/ \
        --header 'In-Progress: false' \
        --header 'On-Behalf-Of: hyrax@testinstance' \
        -F payload=@testPackage2b.zip
      
      

      EXAMPLE RESPONSE

      201 Created
      
      <feed xmlns="http://www.w3.org/2005/Atom">
        <title>Test record 2b</title>
        <content rel="src" href="http://hyrax.digitalnest.co.uk/sword/collections/default/works/jm214p131"/>
        <link rel="edit" href="http://hyrax.digitalnest.co.uk/sword/collections/default/works/jm214p131/file_sets"/>
      </feed>
      

  5. Add new work: Metadata and file in bagit zip file

    1. Add new work: Metadata and file in bagit zip file (binary)

      METHOD

      POST binary data
      

      ENDPOINT

      /sword/collections/[collection_id]/works
      Example: https://hyrax.digitalnest.co.uk/sword/collections/default/works
      

      HEADERS
      Must include the Content-Disposition header with the filename containing the extension .zip

      Content-Type: application/zip
      Packaging: http://purl.org/net/sword/package/BagIt
      Content-Disposition: attachment; filename=testPackage1InBagit.zip
      Content-MD5: c058e3a3eba263df481ebf69ba2305f7
      

      BODY
      binary file zip file of testPackageInBagit.

      NOTE
      The data should contain a metadata file called metadata.xml

      CURL REQUEST

      curl --request POST \
        --url https://hyrax.digitalnest.co.uk/sword/collections/default/works \
        --header 'Content-Disposition: attachment; filename=testPackage1InBagit.zip' \
        --header 'Content-MD5: c058e3a3eba263df481ebf69ba2305f7' \
        --header 'Content-Type: application/zip' \
        --header 'Packaging: http://purl.org/net/sword/package/BagIt' \
        --data-binary @testPackageInBagit.zip
      
      

      EXAMPLE RESPONSE

      201 Created
      
      <feed xmlns="http://www.w3.org/2005/Atom">
        <title>Test record 1</title>
        <content rel="src" href="http://hyrax.digitalnest.co.uk/sword/collections/default/works/5425k968s"/>
        <link rel="edit" href="http://hyrax.digitalnest.co.uk/sword/collections/default/works/5425k968s/file_sets"/>
      </feed>
      

    2. Add new work: payload containing metadata and file in bagit zip (form-data)

      METHOD

      POST multi-part form data
      

      ENDPOINT

      /sword/collections/[collection_id]/works
      Example: https://hyrax.digitalnest.co.uk/sword/collections/default/works
      

      HEADERS
      Must include the Content-Disposition header with the filename containing the extension .zip

      Packaging: http://purl.org/net/sword/package/BagIt
      Content-Disposition: attachment; filename=testPackage1InBagit.zip
      Content-MD5: c058e3a3eba263df481ebf69ba2305f7
      

      FIELDS
      Field name: payload
      Field value: file zip file of testPackageInBagit.

      NOTE
      The data should contain a metadata file called metadata.xml
      If any metadata is sent with the form metadata field, it will be ignored.

      CURL REQUEST

      curl --request POST \
        --url https://hyrax.digitalnest.co.uk/sword/collections/default/works \
        --header 'Content-MD5: 572371fa2ce9e371fbfb87477f8318ec' \
        --header 'Packaging: http://purl.org/net/sword/package/BagIt' \
        -F payload=@testPackage2InBagit.zip
      
      

      EXAMPLE RESPONSE

      201 Created
      
      <feed xmlns="http://www.w3.org/2005/Atom">
        <title>Test record 1</title>
        <content rel="src" href="http://hyrax.digitalnest.co.uk/sword/collections/default/works/5425k968s"/>
        <link rel="edit" href="http://hyrax.digitalnest.co.uk/sword/collections/default/works/5425k968s/file_sets"/>
      </feed>
      

  6. Get work with only metadata

    METHOD

    GET
    

    ENDPOINT

    /sword/collections/[collection_id]/works/[work_id]
    Example: https://hyrax.digitalnest.co.uk/sword/collections/default/works/jm214p12r
    

    HEADERS

    BODY

    CURL REQUEST

    curl --request GET \
      --url https://hyrax.digitalnest.co.uk/sword/collections/default/works/jm214p12r
    

    EXAMPLE RESPONSE

    200 OK
    
    <feed xmlns="http://www.w3.org/2005/Atom" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dc="http://purl.org/dc/elements/1.1/">
        <title>Title, Test record with only metadata</title>
        <content rel="src" href="http://hyrax.digitalnest.co.uk/sword/collections/col1/works/jm214p12r"/>
        <link rel="edit" href="http://hyrax.digitalnest.co.uk/sword/collections/col1/works/jm214p12r/file_sets"/>
        <dc:title>Title</dc:title>
        <dc:title>Test record with only metadata</dc:title>
        <dc:creator>Anusha</dc:creator>
        <dc:contributor>The dublin core generator</dc:contributor>
        <dc:description>This is a test dc record to test the dc crosswalk and creation of a metadata only record</dc:description>
        <dc:license>https://creativecommons.org/licenses/by/4.0/</dc:license>
        <dc:publisher>Digital Nest</dc:publisher>
        <dc:subject>Crosswalk</dc:subject>
        <dc:subject>Sword</dc:subject>
        <dc:language>English</dc:language>
        <dc:identifier>pubs:12345678</dc:identifier>
        <dc:source>http://sword.digitalnest.com</dc:source>
    </feed>
    

  7. Get work with file and metadata

    METHOD

    GET
    

    ENDPOINT

    /sword/collections/[collection_id]/works/[work_id]
    Example: https://hyrax.digitalnest.co.uk/sword/collections/default/works/2z10wq20d
    
    

    HEADERS

    BODY

    CURL REQUEST

    curl --request GET \
      --url https://hyrax.digitalnest.co.uk/sword/collections/default/works/2z10wq20d
    

    EXAMPLE RESPONSE

    200 OK
    
    <feed xmlns="http://www.w3.org/2005/Atom" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dc="http://purl.org/dc/elements/1.1/">
        <title>Test record 3</title>
        <content rel="src" href="http://hyrax.digitalnest.co.uk/sword/collections/col1/works/2z10wq20d"/>
        <link rel="edit" href="http://hyrax.digitalnest.co.uk/sword/collections/col1/works/2z10wq20d/file_sets"/>
        <entry>
            <content rel="src" href="http://hyrax.digitalnest.co.uk/sword/collections/col1/works/2z10wq20d/file_sets/4x51hj00j"/>
            <link rel="edit" href="http://hyrax.digitalnest.co.uk/sword/collections/col1/works/2z10wq20d/file_sets/4x51hj00j"/>
        </entry>
        <dc:title>Test record 3</dc:title>
        <dc:creator>Anusha Ranganathan</dc:creator>
        <dc:creator>Another creator</dc:creator>
        <dc:creator>Yet another creator</dc:creator>
        <dc:contributor>John Smith</dc:contributor>
        <dc:description>This is a test dc record to test the dc crosswalk</dc:description>
        <dc:license>https://creativecommons.org/licenses/by/4.0/</dc:license>
        <dc:publisher>Digital Nest</dc:publisher>
        <dc:subject>Crosswalk</dc:subject>
        <dc:subject>Sword</dc:subject>
        <dc:language>English</dc:language>
        <dc:identifier>pubs:1234</dc:identifier>
        <dc:source>http://sword.digitalnest.com</dc:source>
    </feed>
    

  8. Get work that doesn't exist

    METHOD

    GET
    

    ENDPOINT

    /sword/collections/[collection_id]/works/[work_id]
    Example: https://hyrax.digitalnest.co.uk/sword/collections/default/works/bn999672vdf
    

    HEADERS

    BODY

    CURL REQUEST

    curl --request GET \
      --url https://hyrax.digitalnest.co.uk/sword/collections/default/works/bn999672vdf
    

    EXAMPLE RESPONSE

    400 Bad Request
    
    <sword:error xmlns:sword="http://purl.org/net/sword/" xmlns:arxiv="http://arxiv.org/schemas/atom" xmlns="http://www.w3.org/2005/Atom" href="http://purl.org/net/sword/error/ErrorBadRequest">
      <author>
        <name>Sword v2 server</name>
      </author>
      <title>ERROR</title>
      <updated>2018-07-16T23:38:51Z</updated>
      <generator uri="https://example.org/sword-app/" version="0.1">sword@example.org</generator>
      <summary>Server cannot find work with id bn999672vdf</summary>
      <sword:treatment>processing failed</sword:treatment>
    </sword:error>
    

  9. Get file metadata

    Note
    Returns metadata for file set in work

    METHOD

    GET
    

    ENDPOINT

    /sword/collections/[collection_id]/works/[work_id]/file_sets/[file_set_id]
    Example: http://hyrax.digitalnest.co.uk/sword/collections/default/works/5425k968s/file_sets/73666450z
    

    NOTE
    No check is done to the collection id or work id. Just the file set id needs to exist

    HEADERS

    BODY

    CURL REQUEST

    curl --request GET \
      --url https://hyrax.digitalnest.co.uk/sword/collections/default/works/5425k968s/file_sets/73666450z
    

    EXAMPLE RESPONSE

    200 OK
    
    <feed xmlns="http://www.w3.org/2005/Atom" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dc="http://purl.org/dc/elements/1.1/">
        <title>Swordv2Spec.pdf</title>
        <content rel="src" href="http://hyrax.digitalnest.co.uk/sword/collections/default/works/5425k968s/file_sets/73666450z"/>
        <link rel="edit" href="http://hyrax.digitalnest.co.uk/sword/collections/default/works/5425k968s/file_sets/73666450z"/>
        <dc:title>Swordv2Spec.pdf</dc:title>
        <dc:creator>batchuser@example.com</dc:creator>
    </feed>
    

  10. Add file to existing work (binary)

    NOTE
    A new file set is created with the file and associated to the work

    METHOD

    POST binary data
    

    ENDPOINT

    /sword/collections/[collection_id]/works/[work_id]/file_sets
    Example: https://hyrax.digitalnest.co.uk/sword/collections/default/works/5425k968s/file_sets
    

    HEADERS
    Must include the Content-Disposition header with the filename

    Content-Type: application/pdf
    Packaging: http://purl.org/net/sword/package/Binary
    In-Progress: false
    On-Behalf-Of: hyrax@testinstance
    Content-MD5: 605ae7a8a167bf2bfe031bf3f7378012
    Content-Disposition: attachment; filename=Swordv2Spec.pdf
    

    BODY
    binary file Swordv2Spec.pdf.

    CURL REQUEST

    curl --request POST \
      --url https://hyrax.digitalnest.co.uk/sword/collections/default/works/5425k968s/file_sets \
      --header 'Content-Disposition: attachment; filename=dSwordv2Spec.pdf' \
      --header 'Content-MD5: 605ae7a8a167bf2bfe031bf3f7378012' \
      --header 'Content-Type: application/pdf' \
      --header 'In-Progress: false' \
      --header 'On-Behalf-Of: hyrax@testinstance' \
      --header 'Packaging: http://purl.org/net/sword/package/Binary'
      --data-binary @Swordv2Spec.pdf
    

    EXAMPLE RESPONSE

    200 OK
    
    <feed xmlns="http://www.w3.org/2005/Atom">
        <title>Test record 1</title>
        <content rel="src" href="http://hyrax.digitalnest.co.uk/sword/collections/default/works/5425k968s"/>
        <link rel="edit" href="http://hyrax.digitalnest.co.uk/sword/collections/default/works/5425k968s/file_sets"/>
        <entry>
            <content rel="src" href="http://hyrax.digitalnest.co.uk/sword/collections/default/works/5425k968s/file_sets/2227mp645"/>
            <link rel="edit" href="http://hyrax.digitalnest.co.uk/sword/collections/default/works/5425k968s/file_sets/2227mp645"/>
        </entry>
        <entry>
            <content rel="src" href="http://hyrax.digitalnest.co.uk/sword/collections/default/works/5425k968s/file_sets/73666450z"/>
            <link rel="edit" href="http://hyrax.digitalnest.co.uk/sword/collections/default/works/5425k968s/file_sets/73666450z"/>
        </entry>
    </feed>
    

  11. Update file metadata (binary)

    Note
    The file set metadata is updated

    METHOD

    PUT binary data
    

    ENDPOINT

    /sword/collections/[collection_id]/works/[work_id]/file_sets/file_set_id
    Example: https://hyrax.digitalnest.co.uk/sword/collections/col1/works/5425k968s/file_sets/73666450z
    

    NOTE
    No check is done to the collection id or work id. Just the file set id needs to exist

    HEADERS
    Must include the Content-Disposition header with the filename metadata.xml

    Content-Type: application/xml
    Packaging: application/atom+xml;type=entry
    Content-Disposition: attachment; filename=metadata.xml
    

    BODY
    binary file file metadata in dublin core.

    CURL REQUEST

    curl --request POST \
      --url https://hyrax.digitalnest.co.uk/sword/collections/default/works/5425k968s/file_sets \
      --header 'Content-Disposition: attachment; filename=metadata.xml' \
      --header 'Content-Type: application/xml' \
      --header 'Packaging: application/atom+xml;type=entry'
      --data-binary @file_metadata.xml
    

    EXAMPLE RESPONSE

    200 OK
    

  12. Authorizing sword requests

    If the sword engine in configured to authorize sword requests, in order to interact with all of the above sword end points, the Api-key header must be included in the header along with any other headers needed or recommended by the sword specification.

    An example request is shown below to get the service document Get service document

    METHOD

    GET
    

    ENDPOINT

    /sword/service_document
    Example: https://hyrax.digitalnest.co.uk/sword/service_document
    

    HEADERS

    Content-Type: application/xml
    Api-key: 4d69516e-c7f8-4cff-b611-add6079180dc
    

    The curl request for the service document would now be

    CURL REQUEST

    curl --request GET \
      --url https://hyrax.digitalnest.co.uk/sword/service_document \
      --header 'Content-Type: application/xml' \
      --header 'Api-key:4d69516e-c7f8-4cff-b611-add6079180dc'
    

    EXAMPLE RESPONSE

    200 OK
    
    <service xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:sword="http://purl.org/net/sword/terms/" xmlns="http://www.w3.org/2007/app">
        <sword:version>2.0</sword:version>
        <workspace collections="1">
            <atom:title>Hyrax Sword V2 server</atom:title>
            <collection href="http://hyrax.digitalnest.co.uk/sword/collections/default">
                <atom:title>Default collection</atom:title>
                <accept>*/*</accept>
                <accept alternate="multipart-related">*/*</accept>
                <sword:collectionPolicy>TODO: Collection Policy</sword:collectionPolicy>
                <dcterms:abstract></dcterms:abstract>
                <sword:mediation>true</sword:mediation>
                <sword:treatment>TODO: Treatment description</sword:treatment>
                <sword:acceptPackaging>http://purl.org/net/sword/package/SimpleZip</sword:acceptPackaging>
                <sword:acceptPackaging>http://purl.org/net/sword/package/BagIt</sword:acceptPackaging>
                <sword:acceptPackaging>http://purl.org/net/sword/package/Binary</sword:acceptPackaging>
            </collection>
        </workspace>
    </service>
    

    NOTE
    If you do not include the api-key, you will receive a HTTP 301 response with the error message Not authorized. API key not available.

    Similarly, if the api-key is incorrect, you will receive a HTTP 301 response with the error message Not authorized. API key not found.

    For example, when repeating the same call as above, but with an incorrect api key

    CURL REQUEST

    curl --request GET \
         --url https://hyrax.digitalnest.co.uk/sword/service_document \
         --header 'Content-Type: application/xml' \
         --header 'Api-key:4d69516e-c7f8-4cff-b611'
    

    EXAMPLE RESPONSE

    403 Forbidden
    
    <sword:error 
      xmlns:sword="http://purl.org/net/sword/" 
      xmlns:arxiv="http://arxiv.org/schemas/atom" 
      xmlns="http://www.w3.org/2005/Atom" 
      href="http://purl.org/net/sword/error/TargetOwnerUnknown">
      <author>
        <name>Sword v2 server</name>
      </author>
      <title>ERROR</title>
      <updated>2018-11-13T01:53:15Z</updated>
      <generator uri="https://example.org/sword-app/" version="0.1">
        sword@example.org
      </generator>
      <summary>Not authorized. API key not found.</summary>
      <sword:treatment>processing failed</sword:treatment>
    </sword:error>
    

  13. Update work

    METHOD

    PUT binary data or multi-part
    

    ENDPOINT

    /sword/collections/[collection_id]/works/[work_id]
    Example: https://hyrax.digitalnest.co.uk/sword/collections/col1/works/5425k968s
    

    HEADERS

    Same as the headers in create requests.
    

    CURL REQUEST

    Apart from changing the method from POST to PUT,
    everything else is the same as creating a record 
    

    NOTE
    If there is a metadata file, the metadata is updated. If there is a payload, the file gets added to the work. It will not update any existing file. When updating, you need not include a metadata.xml file.

    Both binary data and multi-part data formats can be used for performing updates.