How get embedded draw.io diagrams when accessing a page via Confluence REST API?
Asked by Markus Perndorfer:

A draw.io diagram on a page used to be an embedded, base64-encoded png in the body.export_view of a page, e.g:  

```
GET?https://confluence.company.com/rest/api/content/123456789?expand=metadata.labels,children.page,version,body.export_view
```

**Old Response**

```
{
  "id": "123456789",
  "type": "page",
  "status": "current",
  ...
  "body": {
    "export_view": {
      "value": "<img class=\"drawio-diagram-image\" src=\"data&colon;image/png;base64,c0debabe..."
    }
  }
}
```

But since a recent upgrade of the draw.io plugin (8.5.1 -\> 9.2.6), I get a useless JS code block for every diagram on a page

**New Response**

```
{ 
  "id": "123456789", 
  "type": "page", 
  "status": "current", 
  ... 
  "body": { 
    "export_view": { 
      "value": "<span id=\"drawio-macro-content-cae9a5a5-bb84-4eba-83d2-b2f5798cf226\" style=\"position:relative;display:inline-block;max-width:100%;overflow:hidden;border:1px solid transparent;\"></span>\n\n<script type=\"text/javascript\">\n(function()\n{\n\t$ = AJS.$;\n\t\n\tvar graphContainer = document.getElementById('drawio-macro-content-cae9a5a5-bb84-4eba-83d2-b2f5798cf226');\n\tvar DrawioProperties = { contextPath : AJS.contextPath() };\n\t\n\tvar readerOpts = {};\n\t\t\treaderOpts.loadUrl = '' + '/rest/drawio/1.0/diagram/crud/..."
    }
  }
}
```

Is there any way to replace the JS code block with e.g. link to the rendered diagram?  
(Maybe a configuration option for the plugin?)

Theoretically I could parse the JS script block and use the properties of readerOpts to construct the link to the rendered diagram that's available as attachment on the page anyway, but I really don't want to go down that rabbit hole.


Answers:
author: David Benson _draw_io_
body: Are you sure it's a change to the plugin and not a Confluence update that caused the change?

comments: author: Markus Perndorfer
body: Reasonably sure, yes. (I'm only a user of this particular confluence server, not an admin)

The change of the output format directly coincides with the plugin update.

I was able to dig up the previous version: 8.5.1


author: Markus Perndorfer
body: Any chance to get the old behaviour back?


author: Boris
body: We have implemented an admin setting which will act as a switch. Default will be 1 which will embed the diagram in the output.

It will be in the next release.


author: Markus Perndorfer
body: that's great to hear!

Looking forward to the next version, so I can remove the JS script block parsing again...

Any ETA on the release?


author: Markus Perndorfer
body: Is this fix in 9.2.8?


author: Boris
body: It is. Search for 'emailpreview' in the docs [here](https://desk.draw.io/a/solutions/articles/16000061128).


author: ee
body: it's version 9.1.

after setting emailpreview=1, the export_view is still js code.

how to rollback to base64 encode images.![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/169468i50EDB64235F5CE42/image-size/large?v=v2&px=999 "image.png")


author: David Benson _draw_io_
body: 9.1 is too old, you need to update to get the change.


Tags: confluence-server

draw.io

rest-api

server