Latest 3.x Release

This documentation covers the latest release of the legacy 3.x Fedora. Looking for another version? See all documentation.

Fedora 4 Development

Looking for Fedora's currently active development?

The cURL application is a command line program for getting or sending files using URL syntax.  It is a popular tool for making REST API calls to Fedora for quick tests, scripted interactions or other cases where a client library or interface is too cumbersome for the need at hand.  While powerful and robust, at times the specific command line parameters required to get the desired behavior from Fedora's REST API are elusive.

To ingest a new object into fedora using a FOXML file from the command line, the following set of parameters is appropriate.

curl -vv -u "username:password" -H "Content-type:text/xml" -d "format=info:fedora/fedora-system:FOXML-1.1" -X POST --upload-file curl-ingest-demo_1-foxml.xml http://localhost:8080/fedora/objects/new

Explanation

  • -vv represents verbose output and while entirely optional may be educational
  • -u "username:password" is the username and password for a user in your Fedora repository that may ingest new objects
  • -H "Content-type:text/xml" specifies the content type for the posted content (in this case, the FOXML data)
  • -d "format=info:fedora/fedora-system:FOXML-1.1" causes the values provided (format) to be included in the POST data
  • -X POST causes the request to use the POST HTTP method
  • --upload-file curl-ingest-demo_1-foxml.xml specifies the FOXML file to be ingested
  • http://localhost:8008/fedora/objects/new the REST URL for creating new objects

Creating New Objects

To create new objects (to which datastreams may be added later) simply omit the "d" and "upload-file" arguments.

Sample FOXML file

curl-ingest-demo_1-foxml.xml
<?xml version="1.0" encoding="UTF-8"?>
<foxml:digitalObject VERSION="1.1" PID="curl-ingest-demo:1"
    xmlns:foxml="info:fedora/fedora-system:def/foxml#"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="info:fedora/fedora-system:def/foxml# http://www.fedora.info/definitions/1/0/foxml1-1.xsd">
    <foxml:objectProperties>
        <foxml:property NAME="info:fedora/fedora-system:def/model#state" VALUE="Active"/>
    </foxml:objectProperties>
    <foxml:datastream ID="DC" STATE="A" CONTROL_GROUP="X" VERSIONABLE="true">
        <foxml:datastreamVersion ID="DC1.0" LABEL="Dublin Core Record for this object"
            MIMETYPE="text/xml" FORMAT_URI="http://www.openarchives.org/OAI/2.0/oai_dc/">
            <foxml:xmlContent>
                <oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/"
                    xmlns:dc="http://purl.org/dc/elements/1.1/"
                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                    xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd">
                    <dc:identifier>curl-ingest-demo:1</dc:identifier>
                    <dc:title>An object ingested by posting a FOXML document to the REST API using CURL.</dc:title>
                </oai_dc:dc>
            </foxml:xmlContent>
        </foxml:datastreamVersion>
    </foxml:datastream>
</foxml:digitalObject>

  • No labels