我正在尝试使用带有ODataQueryOptions的邮递员调用Web API。但是我收到了错误
使用类型检测属性“DeclaringType”的自引用循环 -'Microsoft.Data.Edm.Library.EdmEntityType”。路径'messageArguments [0] .options.Context.Model.SchemaElements [0] .DeclaredProperties [0]'。
以下是API ActionMethod -
[Route("api/get")]
[HttpGet]
public IHttpActionResult Get(ODataQueryOptions<Dummy> options)
{
return null;
}
我的邮递员网址 - https://localhost:44360/api/get/ $ select =姓名
答案 0 :(得分:1)
我在该操作方法上有一个操作过滤器,它将使用Newtonsoft将操作参数转换为JSON并将其记录在文本文件中。问题在于将ODataQueryOptions转换为JSON,这导致自引用循环错误。在转换为JSON时添加忽略自引用JSON设置会引发另一个错误 - “在'System.Web.HttpInputStream''中从'ReadTimeout'获取值时出错”。无论如何,我删除了动作过滤器,它现在工作正常。