2017-04-07 67 views
0

我想使用Cloud REST API和「curl」命令將附件移動到不同的空間(即更新Confluence頁面中附件的父容器)。我擡頭REST API端點的網址,發現這一點:Atlassian Confluence:更新附件的父容器

PUT /rest/api/content/{id}/child/attachment/{attachmentId} 

可能有人爲構建正確JSON輸入來實現這個提供一個例子嗎?我嘗試下面的一個移動稱爲「test.jpeg」與ID「att000」和當前版本5至父ID爲1234的附接,但它未能:

curl -v -u 'admin:password' -X PUT -H 'Content-Type:application/json' -d '{"id":"att000","type":"attachment","title":"test.jpeg","version":{"number":5,"minorEdit":false},"ancestors":[{"id":1234}]' -H ‘X-Atlassian-Token:access-token' https://test.atlassian.net/wiki/rest/api/content/170234/child/attachment | python -m json.tool 

下面給出的錯誤消息

< HTTP/1.1 415 Unsupported Media Type 
. 
. 
. 
No JSON object could be decoded 

謝謝你的時間!

回答

0

我相信你的curl的例子,你正在上傳它的空間,這是不可能的。 Confluence中的附件需要在內容之下。看看下面的例子:

curl -v -S -u admin:admin -X POST -H "X-Atlassian-Token: no-check" -F "[email protected]" -F "comment=this is my file" "http://localhost:8080/confluence/rest/api/content/3604482/child/attachment" | python -mjson.tool 
+0

謝謝你的回覆,薩利赫。我糾正了我的JSON輸入,但我仍然無法收到迴應。我得到「415 Unsupported Media Type」和「No JSON object could be decoding」錯誤。 –

+0

啊gotcha。幾個問題,爲什麼你不使用後,你正在使用put?以及我在curl中沒有看到-F「file = @ locationoffile」。 –

+0

感謝您的回覆!我需要使用「file = @ locationoffile」來更新附件的二進制數據。但是,我試圖只更新附件的非二進制數據(PUT而不是POST)。參考:https://docs.atlassian.com/atlassian-confluence/REST/latest/#content/{id}/child/attachment-update –

0

你必須在請求對象中設置container屬性。

指定"container":{"id":"123456","type":"attachment"}

curl -v -u 'admin:password' -X PUT -H 'Content-Type:application/json' -d '{"id":"att000","type":"attachment","title":"test.jpeg","version":{"number":5,"minorEdit":false},"container":{"id":"123456","type":"attachment"}, "ancestors":[{"id":1234}]' -H ‘X-Atlassian-Token:access-token' https://test.atlassian.net/wiki/rest/api/content/170234/child/attachment | python -m json.tool 

ID =>其中連接正在被移動的頁的ID。

相關問題