How to remove content from Table data macro using API?
Purpose
How do we remove existing Scaffolding data from a Table Data macro using API?
Answer
First, run the GET REST API to get the structure of the JSON.
{confluence-url}/rest/scaffolding/1.0/api/form/{pageID}
You should get the results below:
[ { "macro": "table-data", "name": "tabledata", "value": { "0": [ { "macro": "text-data", "name": "text1", "value": "<p>Text1 Test</p>" }, { "macro": "text-data", "name": "text2", "value": "<p>Text2 Test</p>" } ], "1": [ { "macro": "text-data", "name": "text1", "value": "<p>Text1 Test 2</p>" }, { "macro": "text-data", "name": "text2", "value": "<p>Text2 Test 2</p>" } ] } } ]
Then, change the value to empty:
[ { "macro": "table-data", "name": "tabledata", "value": "" } ]
Run the PUT method using the JSON body in Step 3 with the same REST API as Step 1:
{confluence-url}/rest/scaffolding/1.0/api/form/{page-id}