使用 URIBuilder 的 Azure 价目表 api 查询

Azure Rate Card api query using URIBuilder

我在 grrovy 脚本中使用 URIBuilder 正确构建 URL 时遇到困难。这就是文档所说的样子 -

https://management.azure.com/subscriptions/{subscription-Id}/providers/Microsoft.Commerce/RateCard?api-version={api-version}&$filter=OfferDurableId eq ’{OfferDurableId}’ and Currency eq ’{Currency}’ and Locale eq ’{Locale}’ and RegionInfo eq ’{RegionInfo}’’

我的代码-

def urlRATECARD = 'https://management.azure.com/subscriptions/xxxx-xxxx-xxxx-xxxx/providers/Microsoft.Commerce/RateCard'

def uriRATECARD = new URIBuilder(urlRATECARD)

uriRATECARD.addQueryParam 'api-version','2015-06-01-preview'
uriRATECARD.addQueryParam '$filter', 'OfferDurableId eq`0003P`and Locale eq `en-AU` and Regioninfo eq `AU` and Currency eq `AUD`'

输出 -

https://management.azure.com/subscriptions/xxxx-xxxx-xxxx-xxxx/providers/Microsoft.Commerce/RateCard?api-version=2015-06-01-preview&%24filter=OfferDurableId+eq%600003P%60and+Locale+eq+%60en-AU%60+and+Regioninfo+eq+%60AU%60+and+Currency+eq+%60AUD%60

失败并出现以下错误 -

[Message:Invalid query specified. Please specify valid values for OfferDurableId, Currency, Locale and RegionInfo.]

谁能提供正确的创建方法?

如果您的订阅是 Pay-As-You-GoOfferDurableIdMS-AZR-0003p

你可以检查这个example, before OFFER NUMBER,它需要添加MS-AZR-

我使用 $filter 的美元斜杠字符串解决了这个问题 header -

def urlRATECARD = 'https://management.azure.com/subscriptions/xxxx-xxxx-xxxx-xxxx/providers/Microsoft.Commerce/RateCard'
def uriRATECARD = new URIBuilder(urlRATECARD)
String Filter = $/OfferDurableId eq 'MS-AZR-0003p' and Locale eq 'en-AU' and Regioninfo eq 'AU' and Currency eq 'AUD'/$

uriRATECARD.addQueryParam 'api-version','2015-06-01-preview'
uriRATECARD.addQueryParam '$filter', Filter

创建以下内容 -

https://management.azure.com/subscriptions/xxxx-xxxx-xxxx-xxxx/providers/Microsoft.Commerce/RateCard?api-version=2015-06-01-preview&%24filter=OfferDurableId+eq+%27MS-AZR-0003p%27+and+Locale+eq+%27en-AU%27+and+Regioninfo+eq+%27AU%27+and+Currency+eq+%27AUD%27