来自Powershell的IBM Urbancode AddVersionStatus API调用如何?

时间:2018-05-18 22:14:22

标签: rest powershell urbancode

2 个答案:

答案 0 :(得分:1)

我在尝试做同样的事情时遇到了这篇文章。对我来说,问题在于知道正确的URL是完全(请参见Adam Parsons的答案):

$URL = "url-goes-here"

经过大量的搜索(在此方面,IBM的文档并没有多大价值),我能够通过查看Chrome开发人员工具中的访问量来识别正确的URL(感谢Darrell Schrag的博客)帖子:https://drschrag.wordpress.com/2013/10/03/the-udeploy-rest-api)。

对于那些正在搜索此内容的人,我的PowerShell REST调用序列现在看起来像这样(并成功执行):

$tokenEncoded = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes( "PasswordIsAuthToken:{"token":"$authToken"}" ))
$headers = @{Authorization = "Basic "+$tokenEncoded}

# 1. Get component version ID
$uri = "$uDeployServer:8443/cli/version/getVersionId`?component=$componentName&version=$versionName"
$versionId=Invoke-RestMethod -Uri $uri -Method GET -Headers $headers

# 2. Add component version status
$uri = "$uDeployServer:8443/rest/deploy/version/$versionId/status/$versionStatus"
Invoke-RestMethod -Uri $uri -Method PUT -Headers $headers

答案 1 :(得分:0)

可能是这样的......

$Hash = @{
        Component="StringValue"
        Version="StringValue"
        Status="StringValue"
        }


$Json = $Hash | ConvertTo-Json
$URL = "url-goes-here"
$Cred = Get-Credential

Invoke-RestMethod -Method "POST" -Uri $url -Credential $Cred -Body $Json