【问题标题】:Create/update Product Policy via REST in Azure API Management在 Azure API 管理中通过 REST 创建/更新产品策略
【发布时间】:2017-04-26 16:08:35
【问题描述】:

“创建或更新”产品政策的文档似乎不完整:https://docs.microsoft.com/en-us/rest/api/apimanagement/productpolicy

如您所见,“类型”字段是空的,没有任何内容表明 PUT 操作的主体中应该包含什么内容。有人知道应该在体内做什么吗?非常感谢使用示例。

【问题讨论】:

    标签: json rest put azure-api-management


    【解决方案1】:

    @TheDude,感谢您的关注,我们会解决这个问题。

    查看此文档(它将为您提供标头和示例正文的详细信息)

    https://docs.microsoft.com/en-us/rest/api/apimanagement/apimanagementrest/azure-api-management-rest-api-product-entity#a-namesetpolicya-set-policy-configuration-for-a-product

    【讨论】:

    • 使用 xml 内容类型时出现以下错误:Invoke-RestMethod : {"error":{"code":"ValidationError","message":"Resource was modified since last retrieved .","details":null}} 在 D:\PowerShell Scripts\AddPolicyRest.ps1:31 char:9 + Invoke-RestMethod -Method Put -Uri $url -Header @{ "Authoriza
    • 即使我使用的是 api-version 2016-10-10: "devimsapim.management.azure-api.net/products/54321/…",我也会收到上述错误
    【解决方案2】:

    实际上,上述答案的解决方法是简单地将“If-Match:*”添加到请求标头中。因此,无论何时更新或删除,都必须在请求标头中添加一个“If-Match”值。

    【讨论】:

      猜你喜欢
      • 2022-01-07
      • 2017-11-26
      • 1970-01-01
      • 2018-04-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多