Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Can you add an anchor to content added through the API?

Al Wirtes
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!
February 18, 2022

I am creating documentation in Confluence through the REST API. I use a PUT action to update and entire page of content in Confluence with each transaction. How do I create working anchors and links in my HTML code which is then updated via the REST API?

I see how to manually add anchors by editing the page in Confluence. But I can't find documentation on automatically adding anchors via the API.

Any help would greatly appreciated. Thanks!

1 answer

1 accepted

0 votes
Answer accepted
Pramodh M
Community Champion
February 18, 2022

Hi @Al Wirtes 

If you use a server, use markup to insert the anchor macro via API

If you are using Cloud

First, get the macro in storage format just to get an example of how the API should be formatted to include the same in the update page API

Then use the same format to update the page with anchor macro

Here is the API and ref

https://developer.atlassian.com/cloud/confluence/rest/api-group-content---macro-body/#api-wiki-rest-api-content-id-history-version-macro-id-macroid-get

https://community.atlassian.com/t5/Confluence-questions/Adding-macros-to-pages-createdd-through-REST-API/qaq-p/1477540

Thanks,
Pramodh

Al Wirtes
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!
February 18, 2022

Thank you. But I'm sending full HTML and "representation" is sent to "storage". Markup will only work if I set "representation" to wiki, correct?

Is there any way to create anchors and links while also sending "representation": "storage"?  Thanks.

Pramodh M
Community Champion
February 18, 2022

Perform the GET API and see how the data comes in storage format or you could also see it from the advanced details options. Sending the same format may work (It worked for me in cloud)

Give it a try and let me know 🙂

Thanks

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events