"Error rendering macro" returned V1/V2 get content API with body view expand

XMLWordPrintable

    • 3
    • Severity 3 - Minor

      Issue Summary

      With public pages that contains panels, calling the get content API anonymously (without Authorization and User-Agent headers) will not return body.view.value properly.
      It'll contain divs like this.

      <div class=\"error\">Error rendering macro 'info' : null</div>
      

      Happens with both V1 and V2 API endpoint

      Steps to Reproduce

      1. create a public Confluence page that can be accessed anonymously
      2. put some panels in the page (info, warning, error)
      3. make an anonymous API call without "Authorization" and "User-Agent" headers

      For V1

      curl -H "User-Agent:" 'https://{sitename}.atlassian.net/wiki/rest/api/content/{content_id}?expand=body.view'
      

      For V2

      curl -H "User-Agent:" 'https://{sitename}.atlassian.net/wiki/api/v2/pages/{content_id}?body-format=view'
      

      Expected Results

      the json response should return proper value in body.view.value (without error)

      Actual Results

      We get {}Error rendering macro{} error in the response body.view.value

      Sample body.view.value data that shows the error.

       "<div class=\"error\">Error rendering macro 'info' : null</div><div class=\"error\">Error rendering macro 'info' : null</div><div class=\"error\">Error rendering macro 'warning' : null</div><div class=\"error\">Error rendering macro 'note' : null</div><p />"
      

      Workaround

      Adding 'User-Agent' header in the API call will work in returning the correct response.
      For V1

      curl -H "User-Agent: curl" 'https://{sitename}.atlassian.net/wiki/rest/api/content/{content_id}?expand=body.view'
      

      For V2

      curl -H "User-Agent: curl" 'https://{sitename}.atlassian.net/wiki/api/v2/pages/{content_id}?body-format=view'
      

            Assignee:
            Unassigned
            Reporter:
            Nashid Farhad
            Votes:
            2 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: