Add a Content Item to a Section

The process of adding a content item to a section (or removing it from one) is no different from any other change you might make to a content item. You simply:

  1. Retrieve the content item as an Atom entry resource (as described in Change a Content Item).

  2. Insert one or more Atom link elements to the required sections into the retrieved entry, or remove unwanted link elements. link elements must be inserted as children of metadata:publication elements.

  3. Save the modified entry in a file.

  4. PUT the file back to the same URI from which it was retrieved (as described in Change a Content Item).

The listing below shows a retrieved content item entry in which the metadata:publication element is highlighted:

<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/">  
  <id>http://host-ip-address/webservice/escenic/content/43</id>
  <title type="text">Test</title>  
  <app:edited>2010-06-23T09:09:50.654Z</app:edited> 
  <dcterms:created>2010-06-22T10:22:20.000Z</dcterms:created>
  <author>
    <name>demo Administrator</name>  
    <uri>http://host-ip-address/webservice/escenic/person/2</uri>
  </author>
  <dcterms:identifier>4</dcterms:identifier>  
  <metadata:reference source="ece-auto-gen" sourceid="6d7203c9-27d5-4fce-b14a-a466ead83875"/> 
  <link rel="http://www.vizrt.com/types/relation/home-section" 
        href="http://host-ip-address/webservice/escenic/section/4" 
        title="New Articles" 
        type="application/atom+xml; type=entry"/>
  <link href="http://wrk-ermo:12345/publication-id/incoming/article4.ece" 
        rel="alternate"/>  
  <link href="http://host-ip-address/webservice/escenic/content/preview" rel="http://www.vizrt.com/types/relation/preview"/>          
  <link href="http://host-ip-address/webservice/escenic/lock/article/43" 
        rel="http://www.vizrt.com/types/relation/lock"/>  
  <link rel="http://www.vizrt.com/types/relation/publication" 
        href="http://host-ip-address/webservice/escenic/publication/demo" 
        title="demo" 
        type="application/atom+xml; type=entry"/>  
  <metadata:creator>
    <name>demo Administrator</name>
  </metadata:creator>
  <metadata:publication href="http://host-ip-address/webservice/escenic/publication/demo">
    <link rel="http://www.vizrt.com/types/relation/home-section" 
          href="http://host-ip-address/webservice/escenic/section/4" 
          title="New Articles" 
          type="application/atom+xml; type=entry"/> 
    <link rel="http://www.vizrt.com/types/relation/section" 
          href="http://host-ip-address/webservice/escenic/section/4" 
          title="New Articles" 
          type="application/atom+xml; type=entry"/>
  </metadata:publication>
  <link href="http://host-ip-address/webservice/escenic/content/43" rel="edit"/>  
  <link href="http://host-ip-address/webservice/escenic/content/43" rel="self"/>  
  <content type="application/vnd.vizrt.payload+xml"> 
    <vdf:payload xmlns:vdf="http://www.vizrt.com/types" 
         model="http://host-ip-address/webservice/escenic/model/another">  
      <vdf:field name="TITLE"><vdf:value>Test</vdf:value></vdf:field>
      <vdf:field name="BODY">
        <vdf:value> 
            <div xmlns="http://www.w3.org/1999/xhtml"> 
              <p>This is a test</p>
            </div> 
        </vdf:value>
      </vdf:field>  
    </vdf:payload>  
  </content>  
</entry>

The metadata:publication element contains two link elements. Their href attributes both reference the same section, but they have different rel attribute settings:

http://www.vizrt.com/types/relation/section

This relationship indicates that the content item belongs to a section. The metadata:publication element may contain several links of this type, one for each section to which the content item belongs.

http://www.vizrt.com/types/relation/home-section

This relationship indicates that the referenced section is the content item's home section. The metadata:publication element may contain only one link of this type.

To add the content item to another section, you simply insert another http://www.vizrt.com/types/relation/section link element:

<metadata:publication href="http://host-ip-address/webservice/escenic/publication/demo">
  <link rel="http://www.vizrt.com/types/relation/home-section" 
        href="http://host-ip-address/webservice/escenic/section/4" 
        title="New Articles" 
        type="application/atom+xml; type=entry"/> 
  <link rel="http://www.vizrt.com/types/relation/section" 
        href="http://host-ip-address/webservice/escenic/section/4" 
        title="New Articles" 
        type="application/atom+xml; type=entry"/>
  <link rel="http://www.vizrt.com/types/relation/section" 
        href="http://host-ip-address/webservice/escenic/section/5" 
        title="New Articles" 
        type="application/atom+xml; type=entry"/>
</metadata:publication>

Note that the link element you add must reference an existing section.