因此,首先我對PowerShell相當陌生(在去年),現在我明白了很多,但現在API調用對我來說是新的。Powershell API Web服務調用
我已經弄清楚如何使用不需要任何值的Web調用進行API調用。或者那些不需要數值的數組。如:$ BSSPrincipalManagementWSP.ReadAccount(「1_V4-0119341」)
返回我想要的一切。但是如果我進入$ BSSPrincipalManagementWSP.UpdateAccountValues之類的網頁調用中,第一個變量是賬戶外部ID,但所需的第二個變量是數組中的accountValues。
我已經試過這樣的事情來完成它:
function Update-AccountValues
(
[string]$accountExternalId,
[array]$accountValues = @(Import-Csv -Path $ImportPath)
)
{
$accountValues
$BSSPrincipalManagementWSP.UpdateAccountValues($accountExternalId, $accountValues)
}
Update-AccountValues "1_V4-0119341"
,但我得到了以下錯誤:
Cannot convert argument "accountValues", with value: "System.Object[]", for "UpdateAccountValues" to type "BSSPrincipalManagementNS.AccountValue[]": "Cannot convert value
"@{Key=ScreenSaverTimeoutMinutes; Value=60}" to type "BSSPrincipalManagementNS.AccountValue". Error: "Cannot convert the "@{Key=ScreenSaverTimeoutMinutes; Value=60}" value of type
"System.Management.Automation.PSCustomObject" to type "BSSPrincipalManagementNS.AccountValue".""
At C:\Users\Matt Bergeron\AppData\Local\Temp\ff88f967-9d7c-4f6f-a424-212298a69655.ps1:61 char:2
+ $BSSPrincipalManagementWSP.UpdateAccountValues($accountExternalId, $accountValu ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodException
+ FullyQualifiedErrorId : MethodArgumentConversionInvalidCastArgument
我以爲我傳遞「accountValue對象的數組」,因爲它要求。
CSV文件中的所有內容都是2列,1列爲鍵,另一列列爲值。這些命名與OSS/BSS CHM文件的名稱完全相同。
其他人能告訴我哪裏出錯了嗎?任何幫助將非常感激。
就像我說過的,我對API調用非常陌生,你有什麼建議在哪裏尋找其他API來創建數組?謝謝您的意見。 – chamele0n
@ chamele0n對不起,但我不知道這個API的任何東西。您可以聯繫創建Web服務的人以獲取指向文檔的指針嗎? –