Forums

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

RestSharp page creation issue when double quotes in my body.storage.value

Patch
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!
October 6, 2020

I am using RestSharp for creating pages.  Page creation work great when the html body stay simple, without any (") double quotes characters.

This exemple work great for me:

request.AddParameter("application/json", "{\"type\": \"page\",\"title\": \"TEST\",\n " + AncestorString + " \"space\": {\"key\": \"" + ConfluenceSpaceKey + "\" }, \"body\": {\"storage\": {\"value\": \"<h2>Hello World</h2> \", \"representation\": \"storage\" } } }", ParameterType.RequestBody);

 

As soon I as need to add double quotes characters in the html body:

<h2 style =\"color: Tomato;\"> Hello World </h2>

I get this error:

{"statusCode": 500, "message": "", "reason": "Internal Server Error"}

 

This exemple don't work for me:

request.AddParameter("application/json", "{\"type\": \"page\",\"title\": \"TEST\",\n " + AncestorString + " \"space\": {\"key\": \"" + ConfluenceSpaceKey + "\" }, \"body\": {\"storage\": {\"value\": \"<h2 style =\"color: Tomato;\"> Hello World </h2> \", \"representation\": \"storage\" } } }", ParameterType.RequestBody);

 

Any ideas?
Thx!!

1 answer

1 accepted

0 votes
Answer accepted
Andreas
Contributor
October 8, 2020

Hi @Patch 

so I assume your escaping is wrong: try something like this:

request.AddParameter("application/json", "{\n \"type\": \"page\",\n \"title\": \"new page22\",\n \"space\": {\n \"key\": \"TS\"\n },\n \"body\": {\n \"storage\": {\n \"value\": \"<p style=\\\"color:red\\\">This is a new page</p>\",\n \"representation\": \"storage\"\n }\n }\n}", ParameterType.RequestBody); 

Best

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events