1
我对Powershell和API调用颇为陌生。Invoke-RestMethod在多行上显示结果
我想从Powershell中调用BA API返回BA处于活动状态的所有国家/地区名称。
我已经得到了返回结果的代码,但是所有结果都在单行上返回。我想在一个新行上显示每个结果。 EG每个国家/地区一行。
任何意见将不胜感激。我的代码在下面,但API密钥已被删除。
$uri = 'https://api.ba.com/rest-v1/v1/balocations'
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("client-key",'xxxxxxxxxx')
function FlightLocations($uri, $headers)
{
Invoke-RestMethod -Method GET -Uri $uri -Headers $headers
}
$response = FlightLocations $uri $headers
Write-Host $response.GetBA_LocationsResponse.Country.CountryName
您能否包含您要返回的数据示例? –
谢谢James, 我在代码下面添加了图片。对于PowerShell的结果和原始的API数据。 – tde