【问题标题】:IBM Urbancode AddVersionStatus API call from Powershell How?从 Powershell 如何调用 IBM Urbancode AddVersionStatus API?
【发布时间】:2018-05-18 22:14:21
【问题描述】:

https://www.ibm.com/support/knowledgecenter/en/SS4GSP_6.2.7/com.ibm.udeploy.api.doc/topics/udclient_addversionstatus.html

请问如何使用 Powershell 进行此 PUT 调用?我正在使用 Powershell 5。

【问题讨论】:

    标签: rest powershell urbancode


    【解决方案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
    

    【讨论】:

      【解决方案2】:

      大概是这样的……

      $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
      
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-06-11
      • 2017-08-18
      • 2020-12-15
      • 1970-01-01
      • 1970-01-01
      • 2021-02-17
      • 1970-01-01
      相关资源
      最近更新 更多