Bitbucketリポジトリの[ダウンロード]セクションにファイルをPOSTしようとしています。私はBitbucketのドキュメントのthisページに従っています。私はPowershellスクリプトを書いてこれをしようとしています。アクセストークンの部分について、したがってすべてのテキスト(それは私がのBitbucketを通じて私が作ったアクセストークンを追加する必要がありました仕事に取得するためにはPowershellとBitbucketで動作するPOSTを取得できません
#Invoke-RestMethod -Credential $cred -Uri https://api.bitbucket.org/2.0/repositories/myBitbucketUsername/myBitbucketRepoName/downloads?access_token=9EtOz9JDeWGwxTLKx3ya2oPE8g652GoLN0cMmtD0Ncvkf2OXoio0bcXwSigNE9AXTT2aj6qmbS5XHae7rIc%3D"&"scopes=pipeline%3Avariable+webhook+snippet%3Awrite+wiki+issue%3Awrite+pullrequest%3Awrite+repository%3Adelete+repository%3Aadmin+project%3Awrite+team%3Awrite+account%3Awrite"&"expires_in=3600 -OutFile .\file.txt
:私は、GETメソッドはで動作するように得ることができましたウリの)。
POSTの実行方法がわかりません。私はドキュメントに似たものを含む、いくつか試してみた:
curl -s -u myBitbucketUsername -X POST https://api.bitbucket.org/2.0/repositories/myBitbucketUsername/myBitbucketRepoName/downloads -F [email protected]
このコマンドを実行するとき、私はPowerShellの中に入るエラーがある:私もに追加されたアクセストークンを使用して試してみた
Invoke-WebRequest : Parameter cannot be processed because the parameter name 'u' is ambiguous. Possible matches include:
-UseBasicParsing -Uri -UseDefaultCredentials -UserAgent.
At C:\Users\user\Desktop\ScriptTest.ps1:21 char:9
+ curl -s -u myBitbucketUsername-X POST https://api.bitbucket.org/2.0/reposit ...
+ ~~
+ CategoryInfo : InvalidArgument: (:) [Invoke-WebRequest], ParameterBindingException
+ FullyQualifiedErrorId : AmbiguousParameter,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
URL(GETのやり方に似ています)。
私がPOSTしようとしているファイルは、私のデスクトップにある「Hello.txt」です - 私のPowershellスクリプトと同じ場所です。
アイデア?
編集: 私はブライアンティストのアドバイスに従って、代わりに認証情報を使用しました。今、「Bad Request (400)
」というエラーが表示されます。 PowerShellで
$postParams = @{files='.\Hello.txt'}
Invoke-WebRequest -Credential $cred -Uri https://api.bitbucket.org/2.0/repositories/myBitbucketUsername/myRepoName/downloads -ContentType "multipart/form-data" -Method POST -Body $postParams
'カール-s -u myBitbucketUsername-X POST'あなたがそこに知ってい'myBitbucketUsername'と' -X'の間のスペースにする必要がありますか? – Milk
@Milk oops - それは投稿へのコピーからのタイプミスです。私は投稿を更新しました。 – Roka545