azure - Azure API 管理 - 如何访问产品信息
问题描述
在 APIM 中,我试图在 API 级别策略访问产品信息,因为我必须根据产品名称执行一些逻辑。我正在使用下面的代码
<policies>
<inbound>
<set-variable name="ProductName" value="@{
return context.Product.Name;
}" />
但是,当尝试从邮递员发布请求时,我可以在跟踪中看到以下异常。
{
source: "set-variable",
timestamp: "2020-08-19T14:42:24.4936554Z",
elapsed: "00:00:00.0358409",
data:- {
messages:- [
-{
message: "Expression evaluation failed.",
expression: " return context.Product.Name; ",
details: "Object reference not set to an instance of an object."
},
"Expression evaluation failed. Object reference not set to an instance of an object.",
"Object reference not set to an instance of an object."
]
}
}
为什么它是 null ?是这种情况,我无法访问入站范围内的属性。需要指导。或者,有没有其他方法可以访问 Product.Name 属性。谢谢你。
解决方案
推荐阅读
- ios - 将 UIViewController 与 Storyboard 集成到 SwiftUI 项目中:Transition 后的顶部差距
- java - 从android中的应用程序类调用服务类的静态函数
- c# - 如何从我关闭应用程序的 UserControl 恢复?
- javascript - 使用多个默认参数将值传递给函数
- asp.net-mvc - 使用一个数据库登录 Identity Net 框架和 Net core
- debian - update-alternatives:错误:arptables 的替代 /usr/sbin/arptables-legacy 未注册;不设置
- javascript - 通过 ajax 传递序列化表单和二维数组
- java - 我坚持使用 MVC 模式
- python - 无法将模型中的模块导入到同一文件夹中的 admin.py
- dynamic - 设备中的动态分配使内存复制失败