Confluence rest api wont render SVG as image instead it render it as a text
Asked by ARUNKUMAR ARJUNAN:

Confluence rest api wont render SVG as image instead it render it as a text,

I'm calling the conflence rest api(<https://wiki-mysite.com/rest/api/content/>) to create a sub page using POST in PostMan rest client, the content of the page is

{  
"type":"page",  
"title":"My Sub Page",  
"ancestors":\[{"id":306212948}\],  
"space":{"key":"NPSM"},  
"body":{  
"storage":  
{"value":"\<div\>\<svg xmlns=\\"[http://www.w3.org/2000/svg\\](http://www.w3.org/2000/svg\)" xmlns:xlink=\\"[http://www.w3.org/1999/xlink\\](http://www.w3.org/1999/xlink\)" height=\\"31\\" version=\\"1.1\\" viewBox=\\"0 0 31 31\\" width=\\"31\\"\>\<rect fill=\\"#C3D9FF\\" height=\\"30\\" stroke=\\"#6482B9\\" stroke-width=\\"1.0\\" width=\\"30\\" x=\\"0\\" y=\\"0\\"/\>\<text fill=\\"#774400\\" font-decoration=\\"none\\" font-family=\\"Helvetica\\" font-size=\\"11\\" font-weight=\\"normal\\" text-anchor=\\"middle\\"\>\<tspan x=\\"14\\" y=\\"18\\"\>Start\</tspan\>\</text\>\</svg\>\</div\>",  
"representation":"storage"  
}  
}  
}

this div tag contains a svg to create a small square box with the word "Start" on top of it, After posting this to the confluence api I see just the word start and I'm not seeing the box image behind the start word,

This works perfectly fine if I open this in my Desktop browser, I did the inspect option in the confluence page and I could see the svg tags are stripped off from my Post methed and only the Word "start" inside the div tag is getting read.

Is there any way to make the confluence rest API to keep the svg tags as it is when creating a page?


Answers:
author: ARUNKUMAR ARJUNAN
body: Hi Stephen,

Thanks for your response.

I tried inspecting the browser which displays SVG and verified the html page in Firefox browser and found that there is no change in the source tags and all are the same Firefox is not performing any special changes to the source html page this is the same code which I'm sending to the Confluence rest API, below is the image of that it seems that if the SVG tags are present then Browser is recognizing it and converting it into an image![SVG FIREFOX TEST.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/60913iF1C4B5E73078EEC0/image-size/large?v=v2&px=999 "SVG FIREFOX TEST.PNG")


author: Stephen Sifers
body: Hello Arunkumar and welcome to the Community!

Thank you for reaching out and including great detail around what your needing to accomplish. Currently, within Confluence Server and Cloud there is not an option to include SVG embedded images within a page. This would be why when you attempt this it's stripped and displayed as text. There are feature requests for this which may be found at:

* [CONFSERVER-1762](https://jira.atlassian.com/browse/CONFSERVER-1762)
* [CONFCLOUD-1762](https://jira.atlassian.com/browse/CONFCLOUD-1762)

Alternatively, could you test a GET call on a page which you have an SVG displayed and see how the format is then structured? This could help to understand the method needed to display the image via the REST API which you report seeing via the browser.

We would suggest voting and watching these requests to receive future updates of their status.

Regards,  
Stephen Sifers


Tags: atl-adm

confluence-server

server