【发布时间】:2020-08-19 14:48:58
【问题描述】:
在 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 属性。 谢谢。
【问题讨论】:
-
如果对您有帮助,请采纳。点击复选框变为绿色。
标签: azure azure-api-management