问题描述
在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属性。 谢谢。