POST

Command requires fields node and entry to be filled

  • node - field should contain id of node to publish to
  • item-id - field may contain id of entry to publish
  • expire-at - field may contain timestamp (in XEP-0082 format) after which item should not be delivered to user
  • entry - field should contain multi-line entry content which should be valid XML value for an item

Example content to publish item with id item-1 to node with id example and with content in example field. P

Using XML
with XML payload

In this example we will use following XML payload:

Payload. 

<item-entry>
  <title>Example 1</title>
  <content>Example content</content>
</item-entry>

Request in XML. 

<data>
  <node>example</node>
  <item-id>item-1</item-id>
  <expire-at>2015-05-13T16:05:00+02:00</expire-at>
  <entry>
    <item-entry>
      <title>Example 1</title>
      <content>Example content</content>
    </item-entry>
  </entry>
</data>

Response in XML. 

<result>
  <Note type="fixed">
    <value>Operation successful</value>
  </Note>
</result>

with JSON payload

It is possible to publish JSON payload as value of published XML element. In example below we are publishing following JSON object:

Payload. 

{ "key-1" : 2, "key-2" : "value-2" }

Request in XML. 

<data>
  <node>example</node>
  <item-id>item-1</item-id>
  <expire-at>2015-05-13T16:05:00+02:00</expire-at>
  <entry>
    <payload>{ &quot;key-1&quot; : 2, &quot;key-2&quot; : &quot;value-2&quot; }</payload>
  </entry>
</data>

Response in XML. 

<result>
  <Note type="fixed">
    <value>Operation successful</value>
  </Note>
</result>

Using JSON
with XML payload

To publish XML using JSON you need to set serialized XML payload as value for entry key. In this example we will use following XML payload:

Payload. 

<item-entry>
  <title>Example 1</title>
  <content>Example content</content>
</item-entry>

Request in JSON. 

{
  "node" : "example",
  "item-id" : "item-1",
  "expire-at" : "2015-05-13T16:05:00+02:00",
  "entry" : "<item-entry>
    <title>Example 1</title>
    <content>Example content</content>
  </item-entry>"
}

Response in JSON. 

{
  "Note" : "Operation successful"
}

with JSON payload

As JSON needs to be set as a value of an XML element it will be wrapped on server side as a value for <payload/> element.

Payload. 

{ "key-1" : 2, "key-2" : "value-2" }

Request in JSON. 

{
  "node" : "example",
  "item-id" : "item-1",
  "expire-at" : "2015-05-13T16:05:00+02:00",
  "entry" : {
    "key-1" : 2,
    "key-2" : "value-2"
  }
}

Response in JSON. 

{
  "Note" : "Operation successful"
}

Published item. 

<payload>{ &quot;key-1&quot; : 2, &quot;key-2&quot; : &quot;value-2&quot; }</payload>