NewAg-ApiKey格式错误

问题描述 投票:1回答:1

我正在尝试在aws powershell中运行NewAg-ApiKey cmdlet。我不确定StageKeys的格式。有人可以澄清一下吗?

目前正在将New-AgApiKey写为:

New-AGApiKey -CustomerId '11' -Description 'aa' -Enabled $True -GenerateDistinctId $True -Name 'newAPIKey'-StageKeys [{"RestApiId":'yz50sp19a7'},{"StageName":'wh1'}] -Force

并得到以下错误

在C:\ Users \ sgoswami \ Desktop \ Scripts \ create1.ps1:2 char:132 + ... $ True -Name'newAPIKey'-StageKeys [{“RestApiId”:'yz50sp19a7'},{“Stag ... + ~~~~~~~~~~~~~表达式或语句中出现意外的标记':'yz50sp19a7'。在C:\ Users \ sgoswami \ Desktop \ Scripts \ create1.ps1:2 char:159 + .. .Key'-StageKeys [{“RestApiId”:'yz50sp19a7'},{“StageName”:'wh1'}] -Forc ... + ~~~~~~表达式或语句中的意外标记':'wh1'' 。+ CategoryInfo:ParserError:(:) [],ParseException + FullyQualifiedErrorId:UnexpectedToken

powershell amazon-web-services aws-api-gateway aws-powershell
1个回答
1
投票

尝试创建没有StageKeys的ApiKey。它不是必需参数,并且根据New-AGApiKey documentation,此参数已被弃用,以支持usage plans

-StageKey StageKey []

不适用于使用计划 - 指定与API密钥关联的阶段。 需要?假 位置?命名 接受管道输入?假

此选项在CLI和其他SDK中也已弃用。

如果您仍需要在AWS SDK for .NET文档中使用StageKeys,Amazon.APIGateway.Model.StageKey type is defined here。您可以在powershell中创建此类型的新实例,如下所述,其中具有匹配属性名称和值的powershell用作新对象的输入:

$obj = New-Object Amazon.APIGateway.Model.StageKey -Property @{ RestApiId = "myId"; StageName = "myName" }

要验证类型是否正确:

$obj | get-member

   TypeName: Amazon.APIGateway.Model.StageKey

Name        MemberType Definition
----        ---------- ----------
Equals      Method     bool Equals(System.Object obj)
GetHashCode Method     int GetHashCode()
GetType     Method     type GetType()
ToString    Method     string ToString()
RestApiId   Property   string RestApiId {get;set;}
StageName   Property   string StageName {get;set;}
© www.soinside.com 2019 - 2024. All rights reserved.