【发布时间】:2020-09-20 05:23:07
【问题描述】:
如果我想使用 Nexus API 将工件上传到存储库,有人知道请求正文是什么样的吗?
$token = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes("admin123:password123"))
$header = @{authorization = "Basic $token" }
$body = @{
'raw.dictionary' = '/TestArtifact/Prod/'
'raw.asset1' = 'c:\temp\lenovo.zip'
'raw.asset1.filename' = 'lenovo.zip'
} | Convertto-Json
Invoke-RestMethod -Method POST -Uri 'http://xx.xx.xxx.xxx:8081/service/rest/v1/components?repository=TestRepo' -ContentType 'application/json'-Body $body -Headers $header
我收到“Invoke-RestMethod:响应状态代码不表示成功:415(不支持的媒体类型)”
【问题讨论】:
-
我可以告诉你我认为哪里错了。您没有发送资产。您只是发送一个字符串,而不是文件的二进制数据。这可能就是您收到 415 错误的原因。
标签: powershell api nexus nexus3