title: Get table as JSON from Confluence
body: <p>I'm trying to get table contents from a Confluence page in JSON format. It's all SSO so I can only use an API key and I haven't found a way to access Confluence with the requests library. Unfortunately, the output of the Confluence API is plain html.</p>
  <p>This is what I've got so far. Can the Confluence library output tables in JSON format (rather than displaying the raw html code in a dictionary)?</p>
  <pre><code>from atlassian import Confluence
  import os
  
  user = &quot;me@myself.com&quot;
  api_key = os.environ['confluence_api_key']
  server = &quot;https://xxxxxx.atlassian.net&quot;
  api_url = &quot;/rest/api/content&quot;
  page_id = &quot;12345&quot;
  
  confluence = Confluence(url=server, username=user, password=api_key)
  page = confluence.get_page_by_title(&quot;TEST&quot;, &quot;page 1&quot;, expand=&quot;body.storage&quot;)
  content = page[&quot;body&quot;][&quot;storage&quot;]
  print(content)
  </code></pre>
  <p>And the output looks like this:</p>
  <pre><code>{'value': '&lt;p&gt;Something something.&lt;/p&gt;&lt;p /&gt;&lt;table data-layout=&quot;default&quot; ac:local-id=&quot;xxx&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 226.67px;&quot; /&gt;&lt;col style=&quot;width: 226.67px;&quot; /&gt;&lt;col style=&quot;width: 226.67px;&quot; /&gt;&lt;/colgroup&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th&gt;&lt;p&gt;&lt;strong&gt;name&lt;/strong&gt;&lt;/p&gt;&lt;/th&gt;&lt;th&gt;&lt;p&gt;&lt;strong&gt;type&lt;/strong&gt;&lt;/p&gt;&lt;/th&gt;&lt;th&gt;&lt;p&gt;&lt;strong&gt;comment&lt;/strong&gt;&lt;/p&gt;&lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;p&gt;text1&lt;/p&gt;&lt;/td&gt;&lt;td&gt;&lt;p&gt;varchar(10)&lt;/p&gt;&lt;/td&gt;&lt;td&gt;&lt;p /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;p&gt;123&lt;/p&gt;&lt;/td&gt;&lt;td&gt;&lt;p&gt;int&lt;/p&gt;&lt;/td&gt;&lt;td&gt;&lt;p /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;', 'representation': 'storage', 'embeddedContent': [], '_expandable': {'content': '/rest/api/content/12345'}}
  </code></pre>
  <p>404 error with the requests library:</p>
  <pre><code>request_url = &quot;{server}{api_url}/{page_id}?expand=body.storage&quot;.format(
      server=server, api_url=api_url, page_id=page_id
  )
  
  requestResponse = requests.get(request_url, auth=(user, api_key))
  
  print(requestResponse.status_code)
  </code></pre>