I am trying to create a new Confluence page programmatically using the REST API. Here is the web trace of my JSON request (captured using Fiddler):
POST http://dwvrfpmorin001:8090/rest/api/content HTTP/1.1
Authorization: Basic anVtYnJvOlBhc3N3b3JkMQ==
X-Atlassian-Token: no-check
Accept: application/json
Content-Type: application/json
Host: dwvrfpmorin001:8090
Content-Length: 521
Expect: 100-continue
Connection: Keep-Alive
{
"type":"page",
"title":"My Page",
"space":{"key":"TEAM"},
"body":{
"storage":{
"value":"<p><ac:structured-macro ac:name="toc"/></p><h2>This is a new section</h2><p>here's some regular text</p>",
"representation":"storage"
}
}
}
I get the below following error response:
113
{"statusCode":500,"message":"org.codehaus.jackson.JsonParseException: Unexpected character ('t' (code 116)): was expecting comma to separate OBJECT entries\n at [Source: com.atlassian.confluence.plugins.restapi.filters.LimitingRequestFilter$1@7731274b; line: 8, column: 70]"}
0
I know that "<p><ac:structured-macro ac:name="toc"/></p>" is the part of the request that's failing. If I remove that fragment then the page is created successfully.
I've researched this issue extensively and haven't found the solution. It appears to be a bug. We're on v6.3.3 of Confluence. Please help.
Hi Jonah,
Your code looks sound, however we need to escape those quotes; try running a payload like:
-d '{"type":"page",
"title":"TOC",
"space":{"key":"TEAM"},
"body":{
"storage":{
"value":"<p><ac:structured-macro ac:name=\"toc\"/></p><h2>This is a New Section</h2><p>here'\''s some regular text</p>",
"representation":"storage"}
}
}'
-Shawn
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.