0

Is there a way to use the Confluence REST api to fetch the content of an article if all I have is the tiny url? I know how to do it if I have the page ID or the space/title, but so far I can't figure out a way to translate these tiny urls into something usable.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
gsharp
  • 27
  • 5

2 Answers2

0

You will need some code, but it's possible.

The tiny URL is only a redirect (302) to the page in Confluence.

The process should be something like this:

  • Make a GET request on the Tiny URL. Follow the redirect (302).
  • You will get the page content. If you inspect a Confluence page, you will see that some meta are available:

    <meta name="ajs-page-id" content="6494177"> <meta name="ajs-latest-page-id" content="6494177"> <meta name="ajs-content-type" content="page"> <meta name="ajs-page-title" content="Page Title"> <meta name="ajs-latest-published-page-title" content="Page Title"> <meta name="ajs-parent-page-title" content="My Parent Page Title"> <meta name="ajs-parent-page-id" content="6496957"> <meta name="ajs-space-key" content="CT"> <meta name="ajs-space-name" content="My Space">

  • Parse and get the required values to fetch the content of the page: https://docs.atlassian.com/confluence/REST/latest/#content-getContent.

mtheriault
  • 1,065
  • 9
  • 21
  • I appreciate the response and the workaround but I was hoping for a way to do it through the REST API. – gsharp Aug 29 '16 at 13:01
0

Like @mtheriault said, a workaround is necessary, you can't directly push the tiny url into the REST API. However, there's an easier way than reading the html source:

You need one normal REST call but instead of querying the tinyurl itself, GET the following: [confluenceURL]/pages/tinyurl.action?urlIdentifier=[tinyURLFragment]. If the tiny url fragment is correct, you will get a 302 where the Location header is the fully qualified link to that page. Then you can parse the space key, page title and whatever else you need from it.

rorschach
  • 2,871
  • 1
  • 17
  • 20