Create a Section
The procedure for creating a new section is more or less identical to creating a new content item. Your client application must create an Atom entry resource containing a VDF payload document:
<?xml version="1.0"?> <entry xmlns="http://www.w3.org/2005/Atom" xmlns:app="http://www.w3.org/2007/app" xmlns:metadata="http://xmlns.escenic.com/2010/atom-metadata" xmlns:dcterms="http://purl.org/dc/terms/"> <link rel="http://www.vizrt.com/types/relation/parent" href="http://host-ip-address/webservice/escenic/section/1" title="Home" type="application/atom+xml; type=entry"></link> <content type="application/vnd.vizrt.payload+xml"> <vdf:payload xmlns:vdf="http://www.vizrt.com/types" model="http://host-ip-address/webservice/escenic/publication/publication-id/model/com.escenic.section"> <vdf:field name="com.escenic.sectionName"> <vdf:value>New Section</vdf:value> </vdf:field> <vdf:field name="com.escenic.uniqueName"> <vdf:value>new_section</vdf:value> </vdf:field> <vdf:field name="com.escenic.directoryName"> <vdf:value>new_section</vdf:value> </vdf:field> </vdf:payload> </content> </entry>
This document must then be saved in a file
(my-new-section.xml
, for example) and
POST
ed to the URI of the section collection. This URI
is supplied as a link in the web service's "start" feed resource and has
the link type
http://www.vizrt.com/types/relation/section
(see
http://www.vizrt.com/types/relation/section).
curl --include -u user:password -X POST -H "Content-Type: application/atom+xml" \>
http://host-ip-address/webservice/escenic/section --upload-file my-new-section.xmlHTTP/1.1 100 Continue HTTP/1.1 201 Created Server: Apache-Coyote/1.1 Location: http://localhost:8080/webservice/escenic/section/35 Content-Type: application/atom+xml; type=entry Content-Length: 0 Date: Tue, 20 Mar 2012 06:59:38 GMT
In order for the POST
operation to work, you must
specify a HTTP header as shown above.
If you're using curl
, it's a good idea to specify
--include
with POST
operations:
curl
will then output the response header returned
from the web service as shown above, and you can verify whether or not
the operation was successful:
-
A response code in the 2xx range indicates success.
-
A response code in the 4xx range means that you made an invalid addition and the server won't accept your new content item.
-
A response code in the 5xx range means there is a server error.
The Location
response specifies the location of the
newly-created section record: you can retrieve the section record by
submitting a GET
request to this URL.
A quick way of finding out how to create a correctly structured
section in VDF format is to GET
a section and copy
the structure.