Confluence REST API创建包含HTML内容的页面

时间:2015-08-08 14:00:32

标签: ruby confluence

我需要通过REST API创建一个confluence页面。创建一个简单的页面是有效的,但如果我尝试将内容添加到现有的HTML页面,我会收到http_response 400(错误的请求)。

代码段:

confluence_page_content = File.open("local_html_report", "r").read
json_data = {
  "body" => {
    "storage" => {
    "representation" => "storage",
    "value" => "#{confluence_page_content}"
    }
  },
  "space" => {
   "key" => "#{test_parameters["confluence_space"]}"
  },
  "title" => "TestPageFromChef",
  "type" => "page"
}.to_json 

1 个答案:

答案 0 :(得分:5)

Hy,解决了它:)

代码段:

confluence_page_content = "<ac:structured-macro ac:name=\"html\">
  <ac:plain-text-body><![CDATA[
  #{confluence_page_content}
  ]]></ac:plain-text-body>
  </ac:structured-macro>
  "