POST_items

/items

Adds a new item ot the repository.

There are two methods for creating an item via the REST API; with a packaged zip file which contains a metadata file and one or more bitstream files, or by using an XML or JSON encoded request object.

When submitting an item using the packaged zip file, you will need to design your file with the following structure:

  • package.xml
  • file 1
  • file 2
  • file n

Where package.xml contains the metadata for the item and file 1, 2 and n are one or more bitstreams associated with item.

The package file is made up of both metadata information and the attached bitstreams. Bitstreams are grouped into bundles, with each bundle having a name that matches the corresponding name in the repository configuration.

package.xml
<?xml version="1.0"?> 
<request> 
    <collectionId/> 
    <metadata> 
        <field> 
            <name/> 
            <value/> 
        </field>
    </metadata> 
    <bundles>
        <bundle> 
            <name/> 
            <bitstreams> 
                <bitstream> 
                    <name/> 
                    <mimeType/> 
                    <description/> 
                    <primary>[true|false]</primary> 
                </bitstream> 
                <bitstream> 
                    <name/>
                    <mimeType/>
                    <description/>
                </bitstream>
            </bitstreams>
        </bundle>
    </bundles>
</request>

Below is an example of a package.xml file:

package.xml example
<?xml version="1.0"?> 
<request> 
    <collectionId>242</collectionId> 
    <metadata> 
        <field> 
            <name>dc.title</name> 
            <value>Test Item</value> 
        </field> 
        <field> 
            <name>dc.contributor.author</name> 
            <value>Junwei Lu</value> 
        </field> 
        <field> 
            <name>dc.contributor.author</name> 
            <value>Hayden Young</value> 
        </field> 
        <field> 
            <name>dc.date.issued</name> 
            <value>2012-12-15</value> 
        </field>
    </metadata> 
    <bundles> 
        <bundle> 
            <name>ORIGINAL</name> 
            <bitstreams> 
                <bitstream> 
                    <name>pdf1.pdf</name> 
                    <mimeType>application/pdf</mimeType> 
                    <description>A PDF file.</description> 
                    <primary>true</primary> 
                </bitstream> 
                <bitstream> 
                    <name>test.mp3</name> 
                    <mimeType>audio/x-mpeg</mimeType> 
                    <description>An MP3 file.</description> 
                </bitstream> 
            </bitstreams> 
        </bundle> 
    </bundles> 
</request>

To create an item via curl using a zipped package file, use the --form option to emulate a form post:

curl -i -H "user:username@example.com" "pass:password" -F upload=@"/path/to/images/package.zip" -X POST "http://path/to/rest/items.stream"

Alternatively, an item can be created using an XML or JSON string which defines one or more metadata fields.

Creating an item using raw XML
<?xml version=\"1.0\"?>
<request>
	<collectionId>1</collectionId>
	<metadata>
		<field>
			<name/>
			<value/>
		</field>
 	</metadata>
</request>

PLEASE NOTE: You cannot saved bundles and bitstreams using the XML or JSON endpoints.

To create an item using this method via curl:

curl -i -H "user:username@example.com" -H "pass:password" -H "Content-Type: text/xml" -X POST -d "<?xml version=\"1.0\"?><request><collectionId>1</collectionId><metadata><field><name>dc.title</name><value>Title</value></field><field><name>dc.contributor.author</name><value>Junwei Lu</value></field><field><name>dc.contributor.author</name><value>Hayden Young</value></field><field><name>dc.date.issued</name><value>2011-12-15</value></field><field><name>dc.identifier.uri</name><value>http://hdl.handle.net/123456789/3</value></field></metadata></request>" http://path/to/rest/items.xml

Endpoint URL: http://path/to/rest/items.format 

Formats: xml, json, stream

HTTP Methods: POST

Parameters: None