Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

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

ARUNKUMAR ARJUNAN
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 16, 2019

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\" xmlns: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?

 

2 answers

0 votes
ARUNKUMAR ARJUNAN
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 19, 2019

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 imageSVG FIREFOX TEST.PNG

0 votes
Stephen Sifers
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 18, 2019

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:

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

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events