0

汇合 6.15.2

我需要使用 REST API 将宏插入现有页面。

curl -s -u user:pasw -X POST -H 'Content-Type: application/json' 
     '-d{"id":"246341155",
         "type":"page",
         "space":{"key":"TST"},
         "body":{"value":"<ac:structured-macro ac:name="attachments"><ac:parameter ac:name="old">false</ac:parameter><ac:parameter ac:name="sortBy">name</ac:parameter><ac:parameter ac:name="upload">true</ac:parameter></ac:structured-macro>","representation":"storage"}}' 
     https://localhost:8080/rest/api/content/

响应:

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

使用宏创建页面时,出现同样的错误,页面没有创建:

curl -s -u user:pasw -X POST -H 'Content-Type: application/json' -H 'Accept: application/json' 
     '-d{"type":"page",
         "ancestors":[{"id":246324831}], 
         "title":"New Page",
         "space":{"key":"TST"}, 
         "body":{"storage":{"value":"<ac:structured-macro ac:name="attachments"><ac:parameter ac:name="old">false</ac:parameter><ac:parameter ac:name="sortBy">name</ac:parameter><ac:parameter ac:name="upload">true</ac:parameter></ac:structured-macro>",
                            "representation":"storage"}}}' 
     'https://localhost:8080/rest/api/content/?os_authType=basic'

4

1 回答 1

0

创建带有宏附件的新页面:

curl -s -u user:pasw -X POST 
 -H 'Content-Type: application/json' -H 'Accept: application/json'
 '-d{"type":"page","ancestors":[{"id":**<parent ID>**}], 
     "title":"New page with macro attach","space":{"key":"TST"}, 
     "body":{"storage":{"value":"<p><ac:structured-macro ac:name=\"attachments\" ac:schema-version=\"1\"><ac:parameter ac:name=\"old\">false</ac:parameter><ac:parameter ac:name=\"sortBy\">name</ac:parameter></ac:structured-macro></p>","representation":"storage"}}}' 
 'https://localhost:8080/rest/api/content/?os_authType=basic'

插入页面marco附件:

curl -s -u user:pasw -X PUT 
 -H 'Content-Type: application/json' 
 '-d{"version":{"number":**"2"**},
     "title":"Test page for insert macro",
     "type":"page",
     "body":{"storage":{"value":"<p><ac:structured-macro ac:name=\"attachments\" ac:schema-version=\"1\"><ac:parameter ac:name=\"old\">false</ac:parameter><ac:parameter ac:name=\"sortBy\">name</ac:parameter></ac:structured-macro></p>","representation":"storage"}}}' 
 https://localhost:8080/rest/api/content/**<cuurent page ID>**

于 2021-09-08T20:24:22.283 回答