IBM Connections: Using Connections API on Wiki Pages

From Wiki
Revision as of 16:57, 24 November 2016 by Ebasso (talk | contribs)

THIS DOCUMENT IS ON DRAFT

Using Atom, you can can create, retrieve, update, or delete wiki pages.

I will show some examples, if you want more details see documentation on Working with wiki pages IBM Connections 5.5 API.

First of all you must create a Wiki on Connections, open this wiki and get the wiki-label.

https://{hostname}/wikis/home?lang=en-us#!/wiki/{wiki-label}

Examples;

  • For Wikis inside a community
https://{hostname}/wikis/home?lang=en-us#!/wiki/W0123c2ccb6b6_45aa_bc4e_865da123063a
  • For Wikis outside a community
https://{hostname}/wikis/home?lang=en-us#!/wiki/User Guide

Working with Wiki Pages

Create a Wiki Page

Let's create our data file.

1) Create the file WikiNewPage01.xml, with bellow content:

 <entry xmlns="http://www.w3.org/2005/Atom">
 <title type="text">My First Wiki</title>
 <content type="text/html">
  <![CDATA[<?xml version="1.0" encoding="UTF-8"?><p>
  <strong>Hello World!</strong>
  </p>]]>
 </content>
 <category term="wikipagetag1" />
 <category term="wikipagetag2" />
 <category scheme="tag:ibm.com,2006:td/type" term="page" label="page" />
 </entry>
 

Save.

2) Now run curl comand to create

curl -XPOST "https://{hostname}:{port}/wikis/basic/api/wiki/{wiki-label}/feed"    \
-H "Content-Type: application/atom+xml; charset=utf-8" --data "@WikiNewPage01.xml"  -u {username}:{password} -v -k -L

If no error, refresh you Wiki to see the new page created (on left side).

Create a Wiki Page as Child

You will need the {parentUuid} to create a child page.

Bellow you have 2 ways to get parentUuid:

1) On return of the first you can get the parentUuid, like

Location: https://<HOSTNAME>/wikis/basic/api/wiki/e41bf031-3a55-4bb3-adb4-fc69123a974b/page/92cc601d-2ba2-48d2-bbfe-e08ae9316d6d/entry

2) Open the parent page, click on Page Actions and choose Create Child.

https://<HOSTNAME>/wikis/home?lang=en-us#!/wiki/e41bf031-3a55-4bb3-adb4-fc69123a974b/pages/create?parentId=e4823f5c-ab85-47dd-b34e-8af2aa18e5cf

Let's create our data file.

1) Create the file WikiNewPageChild01.xml, with bellow content:

 <entry xmlns="http://www.w3.org/2005/Atom">
 <title type="text">My First Child Wiki</title>
 <content type="text/html">
  <![CDATA[<?xml version="1.0" encoding="UTF-8"?><p>
  <strong>Hello World! Child</strong>
  </p>]]>
 </content>
 <category term="wikipagetag1" />
 <category term="wikipagetag2" />
 <category scheme="tag:ibm.com,2006:td/type" term="page" label="page" />
 <parentUuid xmlns="urn:ibm.com/td">{parentUuid}</parentUuid>
 </entry>
 

Replace the parentUuid and Save.

2) Now run curl command to create, with a new X-Update-Nonce header:

curl -XPOST "https://{hostname}:{port}/wikis/basic/api/wiki/{wiki-label}/feed"    \
-H "X-Update-Nonce: <NONCE>" -H "Content-Type: application/atom+xml; charset=utf-8" --data "@WikiNewPageChild01.xml"  
-u {username}:{password} -v -k -L

If no error, refresh you Wiki to see the new page created (on left side).

Update a Wiki Page

Retrieving a Wiki Page

Delete a Wiki Page

Tips

Issues with content element

  • {wiki-label} is the wiki to which you want to add the page.
  • Prefixing the html in the content element with the following:
<![CDATA[<?xml version="1.0" encoding="UTF-8"?>

and ending it with:

]]>

fixes an issue to display content.

  • Use
    or

    to restrict content.

Tags

Use

 <category term="wikipagetag1" />

to tag your wiki page.


Ver também