Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to create page properties macro using REST API?

I am following the API reference given below:
https://developer.atlassian.com/cloud/confluence/rest/api-group-content-properties/#api-wiki-rest-api-content-id-property-post

But, the example is not well-crafted. I am not getting how to pass my content in the page properties macro and nothing present about "value" keyword.

Basically I want to create a Table as page properties in the confluence page so that I can link it to some other page. For testing purpose the payload that I am using is given below:

```

payload = {
        "key""spiderman_test1",
        "value":[],
        "body": {
            "storage": {
                "value""<p>Enjoy the API</p>",
                "representation""storage",
            }
        }
    }

```

But it didn't reflected any change on the actual page.

 

Please help me out in what should be the payload for this api. Thanks!

2 answers

1 vote
Dominic Lagger Community Leader Jan 05, 2022

Hi @nitesh yadav 

I'm not sure, whether you can just update a table with confluence REST API.

What I would do is: 

  1. Get the actual Content
  2. Change the content
  3. Put back the content

Your payload code needs the storage value of a page. Would be something like this

"body":{"storage":{"value":"<ac:structured-macro ac:name=\"details\" ac:schema-version=\"1\" data-layout=\"default\" ac:local-id=\"4d09c679-fc74-42e0-b299-b42b0f2374d6\" ac:macro-id=\"9aaba42d-3e46-49e5-92e2-de133b81965f\"><ac:rich-text-body><table data-layout=\"default\" ac:local-id=\"ea2f8c8e-ec48-49ab-bc8e-3d635f6fc357\"><colgroup><col style=\"width: 226.67px;\" /><col style=\"width: 226.67px;\" /><col style=\"width: 226.67px;\" /></colgroup><tbody><tr><th><p><strong>Test</strong></p></th><th><p><strong>test</strong></p></th><th><p><strong>test</strong></p></th></tr><tr><td><p>a</p></td><td><p>b</p></td><td><p>c</p></td></tr><tr><td><p>d</p></td><td><p>e</p></td><td><p>f</p></td></tr></tbody></table></ac:rich-text-body></ac:structured-macro>","representation":"storage"

Hope this helps

Regards, Dominic

Just as a general tip: if you're working with page or space properties a lot, I can recommend the Property Inspector by Lively Apps. It's a free app that lets you view and edit properties in a UI. Quite helpful for debugging and changing pages to use the old editor. :)

EDIT: Whoops, I think you were talking about the Page Properties Macro and not about Page Properties? If that's the case: please ignore my answer.

Cheers,
Sven

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Site Admin
TAGS
Community showcase
Published in Confluence Cloud

🏠 Say hello to the new Confluence Home!

Hi Atlassian Community, My name is DJ Chung, and I’m a Product Manager on the Confluence Cloud team. Today, I’m excited to share a new and improved version of Home. The new Home helps you ...

43,596 views 33 135
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you