This question is in reference to Atlassian Developer Documentation: Confluence REST API Examples
I am working on creating pages in Confluence from the command line. Specifically, I want to move an old documentation system into Confluence. I have tried to use the REST API examples, but they only work for trivially easy content (a single sentence for example).
Command line code:
curl -v -u u:p -X POST -H "Content-Type: application/json" --data-binary @Netsuite_Features.txt https://confluence/rest/api/content/ -k
Netsuite_Features.txt content:
{"type":"page","ancestors":[{"type":"page","id":99231339}],"title":"Netsuite","space":{"key":"LD"},"body":{"storage":{"value":"Back to\n\ntesting \\n double \r sasdf \\r testing \r\n again \\r\\n work please","representation":"storage"}}}
The resulting confluence page that is created:
Back to testing \n double sasdf \r testing again \r\n work please
You will notice that some of the new lines are swallowed and in some cases replaced with spaces. I am using --data-binary in my curl call so that the new lines would be preserved (https://confluence.atlassian.com/jirakb/objects-sent-to-jira-via-curl-in-json-format-have-line-breaks-stripped-321857070.html)
I have been stuck on this for a long time. I have tried a lot of things:
Can anyone help me? I am completely blocked and I have 2500 files to move into confluence.
Extra detail:
Community moderators have prevented the ability to post new answers.
I never got this working. Instead I scraped the wiki pages I wanted and exported them as HTML and then I did an Import through the Content Tools section of Confluence.
Seems curl is not your friend, have you tried the confluence-cli tools? Although the examples page is not working, i am pretty sure you can find your way by looking the how to's and there is an addPage command that should fit your needs
addPage - Add a new page. Required parameters: space, title, content or file Optional parameters: parent, labels, replace, content2, findReplace, findReplaceRegex, noConvert, markdown, encoding
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have not tried confluence CLI, but it is worth a shot. I am not sure the problem is with Curl. The Atlassian docs even use curl in the examples; I think it is the API itself swallowing these characters.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
CLI is deffo worth to check. Using --data-binary curl should send new lines, but if you suspect that you are writing something wrong, then you can use the REST browser to check the API.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.