2017-04-07 16 views
0

Cloud REST APIと「curl」コマンドを使用して、添付ファイルを別のスペースに移動したい(Confluenceページ内の添付ファイルの親コンテナを更新する)。私は、REST APIエンドポイントのURLを見て、これを見つけた:Atlassian Confluence:添付ファイルの親コンテナを更新する

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

誰かがこれを達成するために、正しく構築JSON入力のための例を提供してもらえますか?私はID「att000」とID 1234の親への現在のバージョン5で「test.jpeg」と呼ばれる添付ファイルを移動するには、以下のいずれかを試してみましたが、それは失敗します。下記の

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

返事ありがとうございます、Saleh。 JSON入力を修正しましたが、まだ応答がありません。 「415 Unsupported Media Type」と「JSONオブジェクトがデコードできない」というエラーが表示されます。 –

+0

ああああ。いくつかの質問、なぜあなたは投稿を使用していない、あなたはputを使用していますか?同様に私はあなたのカールで-F "file = @ locationoffile"を見ていません。 –

+0

あなたの返信ありがとう!添付ファイルのバイナリデータを更新するには、 "file = @ locationoffile"を使用する必要があります。しかし、私は添付ファイル(POSTではなくPUT)の非バイナリデータのみを更新しようとしています。リファレンス: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を指定します。

関連する問題