Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Richard Wang our head of customer service explains how we can connect to the API of Confluence.

...

We need to authenticate with this API.

The easiest way is to use Base Auth.We need to use the Confluence GUI to create a token to combine your email address basic access authentication. For the “username” we use our email address that we have in Confluence. For the password we get what Confluence calls an “ApiToken”. This is a special password that you create through the Confluence GUI as described in the video.

This is some example code showing an API call to retrieve one page from the confluence API.

Code Block
languagelua
-- The main function is the first function called from Iguana.
function main()
   local ApiToken = "5gBjjIjuys5K0S6ggg3u94A2"
   local BaseToken = filter.base64.enc("firstnamefirst.lastname@interfacewarelast@interfaceware.com:"..ApiToken)
   local Page = '2101313577'
   local BaseUrl = "https://interfaceware.atlassian.net/wiki/rest/api/";
   
   local Data, Code, Headers = net.http.get{ 
      url = BaseUrl..'content/'..Page,
      parameters={
         expand='body.view'
      }, 
      headers = {
         Accept="application/json",
         Authorization="Basic "..BaseToken
      },
      live = true
   }
   local J = json.parse{data=Data}
   trace(J.body.view.value)
end

...

Code Block
languagehtml
<p>People read and comprehend small documents faster and more completely.</p>
<p>See why <a href="/wiki/spaces/EC/pages/2101706780/Short+emails+are+better" data-linked-resource-id="2101706780" data-linked-resource-version="1" data-linked-resource-type="page">short emails </a>are also better.</p>

Further reading

...