gpt4 book ai didi

azure - 在 Azure API 管理入站策略部分获取路由参数

转载 作者:行者123 更新时间:2023-12-02 22:57:22 24 4
gpt4 key购买 nike

我有一个带有模板参数的 URL。

https://test.azure-api.net/HelperFunction/{siteId}/lots/InventoryItem/{itemId}
https://test.azure-api.net/HelperFunction/122/lots/InventoryItem/12

我想阅读入站策略部分中的模板/路径参数。

我正在尝试如下。但它只会获取查询字符串参数。我想获取路径参数。

 <inbound>
<set-body>@{
JObject transBody = new JObject();
transBody.Add("Arguments",
new JObject
{
{"method", context.Request.Method},
{"parameters", context.Request.Url.QueryString},
});

//Add all json properties as arg
transBody.Add("UriPath", context.Request.Url.Path);
return transBody.ToString();
}</set-body>
<base />
</inbound>

我的要求是将路由参数读取为

"siteId" : 122,
"itemId" : 12

如有任何帮助,我们将不胜感激。

最佳答案

context.Request.MatchedParameters["siteId"]context.Request.MatchedParameters["itemId"]

上下文变量的其余部分可以在这里找到:https://learn.microsoft.com/en-us/azure/api-management/api-management-policy-expressions#ContextVariables

关于azure - 在 Azure API 管理入站策略部分获取路由参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60988708/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com