Adding link to Confluence Page Via Rest API

John Everett
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 20, 2018

Hi Everyone,

I would appreciate it if someone would help me determine how to add links to external resources via the API.

ie.  
... storage:{"value":"New content -- [Atlassian|http://atlassian.com]"} ...

Will just update/create a page with the bracketed string printed rather than creating an embedded link.

 

Thanks in advance,
John

1 answer

0 votes
Eric Lam
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 27, 2018

Hey John,

The actual format of the text to post is Confluence's internal Storage Format. The easiest way to check the correct syntax of a page is save a page in Confluence and then click on the top right "..." and click "View Storage Format". This is the text that would need to be posted via the REST API.

Here's an example!

My Confluence page:

ConfluencePage.png

And here's the raw JSON I am posting to:

URL: 

{
"type":"page",
"title":"Test page from REST API",
"body":{ "storage":{"value":
"<p>Link to&nbsp;<a href=\"https://community.atlassian.com\">Atlassian Community</a></p><p><br /></p><p><ac:link><ri:page ri:content-title=\"Test page\" /></ac:link></p>",
"representation":"storage"}},
"space":{"key":"PD"}
}

(remember to escape the quotes)

I've provided two linking methods in the above example:

  1. The first links to Atlassian Community
  2. The second link is to a Confluence page with page title "Test Page"

 

Cheers,

Eric

Pavel Potcheptsov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 27, 2018

Eric, do you have an idea how to get page's content through API ( i.e. content of "Value") in human readable format, I mean with line breaks as it looks if you open "View Storage Format" or open "Source editor" in Edit mode?

"View Storage Format"

kishore S
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 17, 2020

Hello Eric,

I am currently looking for similar requirement of getting clickable links using json restful table. It would be helpful if u can suggest if you found a way for the problem

Cheers,

Kishore

Venkatesh Nadamuni
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 21, 2024

Hi Eric,

I have the same question as Kishore.  Is there a way to get clickable links into the table as content?  I have tried a few iterations, but I keep getting just HTML syntax showing inside the cell

(such as:  <a href=https://myapp.mydomain.com>https://myapp.mydomain.com</a>)

Thanks

Venkatesh

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events