Rest APIs to fetch particular macro form all confleunce pages and delete that

Hi Team,

Can anyone please help me with the rest APIs to fetch the content having some specific macro and then delete that macro from all the pages.

My usecase: I need to delete “Page Info” macro (Bundled Macros) from all of the confluence pages and need to hard code the value.
Can any one please help me.

Thanks,
Vikas

To find which pages contain the macro, do a CQL search for that macro by its name.

https://your-domain.atlassian.net/wiki/rest/api/content/search?cql=macro=XYZ

There is no REST API endpoint that will just ‘delete’ a macro from a page. You have to download the whole content of that page, process that content in your code to remove the macro part, then upload the modified content back into the page.

PS. You’ve tagged your original post with Confluence CLOUD, Confluence SERVER and Confluence DATACENTRE… even ScriptRunner. It’s considered good etiquette to only tag your questions with the applicable tags, and not use a ‘scatter gun’ approach, as it gets confusing as to which platform / method you are actually referring to, plus it makes your post appear in forum sections it doesn’t belong in.

Hi @sunnyape ,
Thanks for your reply and advice I will take care of this and have removed all these extra tags.

@sunnyape, with this API I am getting HTML content which is in effect after macro processing.
I want to get the raw content which is having macro id and all. Can u help me to fetch that raw content please.

Expected Raw content type:

<p>
                <ac:structured-macro ac:macro-id="1b5572ce-2453-4c4e-bc45-88b3e14524d33" ac:name="page-info" ac:schema-version="1">
                  <ac:parameter ac:name="">created-date</ac:parameter>
                </ac:structured-macro>
              </p>

Getting this one:

<p> <time data-sort-value=\"2021-11-16\" datetime=\"2021-11-16\" class=\"date-upcoming conf-macro output-block\" data-hasbody=\"false\" data-macro-name=\"page-info\">Nov 16, 2021 08:36</time></p>

Thanks,
Vikas