IBM Connections: Using Connections API on Wiki Pages: Difference between revisions

From Wiki
No edit summary
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
'''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 [https://www-10.lotus.com/ldd/lcwiki.nsf/xpAPIViewer.xsp?lookupName=IBM+Connections+5.5+API+Documentation#action=openDocument&res_title=Working_with_wiki_pages_ic55&content=apicontent Working with wiki pages IBM Connections 5.5 API].
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 [https://www-10.lotus.com/ldd/lcwiki.nsf/xpAPIViewer.xsp?lookupName=IBM+Connections+5.5+API+Documentation#action=openDocument&res_title=Working_with_wiki_pages_ic55&content=apicontent Working with wiki pages IBM Connections 5.5 API].
After read this article see [[IBM Connections: Creating Wiki pages with advanced templates]]


= Working with Wiki Pages =  
= Working with Wiki Pages =  


== Getting wiki-label ==
== Getting wiki-label ==
Line 149: Line 149:
Run curl  
Run curl  


  curl -X DELETE "https://'''{hostname}'''/wikis/basic/api/wiki/{wiki-id_or_label}/page/{page_id_or_label}/entry"    \
  curl -X '''DELETE''' "https://'''{hostname}'''/wikis/basic/api/wiki/{wiki-id_or_label}/page/{page_id_or_label}/entry"    \
  -H "Content-Type: application/atom+xml; charset=utf-8" '''-o output.xml''' \
  -H "Content-Type: application/atom+xml; charset=utf-8" \
  -u {username}:{password} -v -k -L
  -u {username}:{password} -v -k -L


Line 158: Line 158:
=== Issues with content element ===
=== Issues with content element ===


* {wiki-id_or_label} is the wiki to which you want to add the page.
To avoid problems with html content element add CDATA tags


* Prefixing the html in the content element with the following:
  <nowiki><![CDATA[<?xml version="1.0" encoding="UTF-8"?></nowiki>
 
'''{PUT YOUR CONTENT HERE}'''
  <![CDATA[<?xml version="1.0" encoding="UTF-8"?>
  <nowiki>]]></nowiki>
 
and ending it with:
 
  ]]>


fixes an issue to display content.
fixes an issue to display content.


* Use <div> or <p> to restrict content.
* Use <nowiki><div></div></nowiki> or <nowiki><p></p></nowiki> to restrict content.
 


=== Tags ===
=== Tags ===
Line 184: Line 179:


= Ver também =
= Ver também =
* [[IBM Connections: Creating Wiki pages with advanced templates]]


* Mais Artigos sobre [[IBM Connections]]
* Mais Artigos sobre [[IBM Connections]]

Latest revision as of 19:22, 24 November 2016

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.

After read this article see IBM Connections: Creating Wiki pages with advanced templates

Working with Wiki Pages

Getting wiki-label

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

https://{hostname}/wikis/home?lang=en-us#!/wiki/{wiki-id_or_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

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 -X POST "https://{hostname}/wikis/basic/api/wiki/{wiki-id_or_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:

  • On response from first curl command, you can get the parentUuid, like
https://<HOSTNAME>/wikis/basic/api/wiki/{wiki-id_or_label}/page/92cc601d-2ba2-48d2-bbfe-e08ae9316d6d/entry
  • Open the parent page, click on Page Actions and choose Create Child. The new url
-> https://<HOSTNAME>/wikis/home?lang=en-us#!/wiki/{wiki-id_or_label}/pages/create?parentId=92cc601d-2ba2-48d2-bbfe-e08ae9316d6d

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 -X POST "https://{hostname}/wikis/basic/api/wiki/{wiki-id_or_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

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

 <entry xmlns="http://www.w3.org/2005/Atom">
 <title type="text">My Second Child Wiki</title>
 <content type="text/html">
  <![CDATA[<?xml version="1.0" encoding="UTF-8"?><p>
  <strong>Hello World! Version 1</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 -X POST "https://{hostname}/wikis/basic/api/wiki/{wiki-id_or_label}/feed"    \
-H "X-Update-Nonce: <NONCE>" -H "Content-Type: application/atom+xml; charset=utf-8" --data "@WikiNewPageChild02.xml"  \
-u {username}:{password} -v -k -L

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

3) Change file WikiNewPageChild02.xml, from

<strong>Hello World! Version 1</strong>

to

<strong>Hello World! Version 2 update after version 1</strong>

Save file

4) Get {page_id_or_label}

You can get page_id from last curl command or from open wiki page and get link on "Feed for this page", like

"https://{hostname}/wikis/basic/api/wiki/{wiki-id_or_label}/page/62e04284-194e-4564-bb68-6f55486d70e6/feed?category=version

5) Run curl again

curl -X PUT "https://{hostname}/wikis/basic/api/wiki/{wiki-id_or_label}/page/{page_id_or_label}/entry?createVersion=true"    \
-H "Content-Type: application/atom+xml; charset=utf-8" --data "@WikiNewPageChild02.xml"  \
-u {username}:{password} -v -k -L

we use createVersion=true, to create a new version of wiki page, if you don't want a new version change createVersion=false.

Retrieving a Wiki Page

Run curl again

curl -X GET "https://{hostname}/wikis/basic/api/wiki/{wiki-id_or_label}/page/{page_id_or_label}/entry"    \
-H "Content-Type: application/atom+xml; charset=utf-8" -o output.xml \
-u {username}:{password} -v -k -L

To retrieve wiki page using anonymous access, use url /wikis/basic/anonymous/api/wiki/{wiki-label}/page/{page-label}/entry

Delete a Wiki Page

Run curl

curl -X DELETE "https://{hostname}/wikis/basic/api/wiki/{wiki-id_or_label}/page/{page_id_or_label}/entry"    \
-H "Content-Type: application/atom+xml; charset=utf-8"  \
-u {username}:{password} -v -k -L

Tips

Issues with content element

To avoid problems with html content element add CDATA tags

<![CDATA[<?xml version="1.0" encoding="UTF-8"?>
{PUT YOUR CONTENT HERE}
]]>

fixes an issue to display content.

  • Use <div></div> or <p></p> to restrict content.

Tags

Use

 <category term="wikipagetag1" />

to tag your wiki page.


Ver também