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

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

Sample FOXML file

<?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>