Command requires fields node
and entry
to be filled
node
- field should contain id of node to publish toitem-id
- field may contain id of entry to publishexpire-at
- field may contain timestamp (in XEP-0082 format) after which item should not be delivered to userentry
- 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
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>
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>{ "key-1" : 2, "key-2" : "value-2" }</payload> </entry> </data>
Response in XML.
<result> <Note type="fixed"> <value>Operation successful</value> </Note> </result>
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" }
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>{ "key-1" : 2, "key-2" : "value-2" }</payload>