C# API将一个属性从guid更改为字符串后返回500错误
我有一个返回对象列表的API。对象的字段类型为C# API将一个属性从guid更改为字符串后返回500错误,c#,ajax,serialization,http-status-code-500,C#,Ajax,Serialization,Http Status Code 500,我有一个返回对象列表的API。对象的字段类型为IEnumerable。该字段最初由Guid字符串列表填充,在Sitecore中设置为多列表: characteristics.VertWilt = item.Fields.Get("vert wilt") != null ? item.Fields.Get("vert wilt").Split(',').Select(f =>f) : null; 但是,我希望取而代之的是检索多列表项的值,而不是Guid ID,因为我不希望Guid显示在我的
IEnumerable
。该字段最初由Guid字符串列表填充,在Sitecore中设置为多列表:
characteristics.VertWilt = item.Fields.Get("vert wilt") != null ? item.Fields.Get("vert wilt").Split(',').Select(f =>f) : null;
但是,我希望取而代之的是检索多列表项的值,而不是Guid ID,因为我不希望Guid显示在我的页面上。因此,我将行改为:
characteristics.VertWilt = item.Fields.Get("vert wilt") != null ? item.Fields.Get("vert wilt").Split(',').Select(f => service.GetItem<IDropdownItem>(Guid.Parse(f)).Value) : null;
data
按原样填充,字段特征。vertwlt看起来像option1、option2、option3
而不是3F9F1AFC-4DD7-4445-83E2-CCBBB62BFF78,8A40AF0E-3F79-4060-BD9D-EE0A29CB1D52、b59a791-5917-45B6-BB2F-fee433fee6039
但是,在控制台中,我看到一个500错误,我的数据没有显示在页面上。我用Firebug检查错误
"message": "An error has occurred.",
"exceptionMessage": "Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
)."
为什么它需要Guid?这需要在哪里改变
"message": "An error has occurred.",
"exceptionMessage": "Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
)."