Confluence Rest更新页面从文件

时间:2016-11-26 04:27:33

标签: bash curl confluence

我可以使用简单的内容成功创建和更新Confluence维基页面。但是,当尝试使用多个字符串进行更新时,我收到错误。

我在Markdown格式化的git存储库中有一组文档。由于遗留需求,我使用pandoc将这些转换为word以在文档系统中部署。我们正在转向Confluence,因此我希望将更新部署为维基页面。

我有页面ID,版本和标题

echo "update page ${title} - ${pagid}/${pagver}"
content=$(pandoc -t HTML ${file})

json="{"
json+='"id":"'${pagid}'","title":"'${title}'","type":"page",'
json+='"space":{"key":"'${SPACE}'"},'
json+='"version":{"number":"'${pagver}'"},'
json+='"body":{"storage":{"value":"'${content}'","representation":"storage"}}'
json+="}"

${curlcmd} -n -X PUT -H 'Content-Type: application/json' --data-raw "${json}" ${apilb}/content/${pagid} 2>/dev/null

如果我将内容设置为<p>this is test content</p>,则可以正常使用。但是复杂的html会出现这个错误:

{"statusCode":500,"message":"org.codehaus.jackson.JsonParseException: Illegal unquoted character ((CTRL-CHAR, code 10)): has to be escaped using backslash to be included in string value\n at [Source: org.apache.catalina.connector.CoyoteInputStream@22ae1ec8; line: 1, column: 157]"}

有没有更好的方法来发送文件输出来更新Confluence维基页面?

1 个答案:

答案 0 :(得分:0)

我建议在Confluence命令行界面(CLI)中查看storePage

https://bobswift.atlassian.net/wiki/display/CSOAP/Documentation#Documentation-runFromAttachmentList

https://marketplace.atlassian.com/plugins/org.swift.confluence.cli/cloud/overview?src=sidebar

如果你以前没有,你应该可以获得这个免费的踪迹。