Important Update: Community URLs redirect issues are partially resolved. Learn More. .
2018-04-20 12:11 PM
Wondering why this works - api/core/datafeed?$orderby=Name asc in my non-prod environment but not my prod environment.
I want to pull all datafeeds and order them. Same exact code works in my non-prod but not my prod.
2018-04-20 12:23 PM
I was able to reproduce the behavior too. I suspect 6.2.x didn't support OData for this specific call OR it was a defect fixed in 6.3.x.
When it fails in 6.2.x, I receive the following error:
[
{
"Links": [],
"RequestedObject": {},
"IsSuccessful": false,
"ValidationMessages": [
{
"Reason": "WebApi:WebApiOdataProcessExceptionReason",
"Severity": 3,
"MessageKey": "WebApi:WebApiOdataProcessException",
"Description": "Type 'Default.<>f__AnonymousType13_3OfGuid_String_Boolean' does not have a property 'Name'.",
"Location": -1,
"ErroredValue": null,
"Validator": "ArcherTech.Web.Api.OData.Processor.ODataProcessor, ArcherTech.Web.Api.OData, Version=6.2.0.1177, Culture=neutral, PublicKeyToken=null",
"XmlData": null,
"ResourcedMessage": "Exception processing OData query."
}
]
}
]
Here are a couple ways to help sort JSON objects based on a JSON property. First line of code is for Ascending.
VB.NET
propSorted = obj.Properties.Select(Function(p As Newtonsoft.Json.Linq.JProperty) p.Name).OrderBy(Of String)(Function(s As String) s).ToList()
propSorted = obj.Properties.Select(Function(p As Newtonsoft.Json.Linq.JProperty) p.Name).OrderByDescending(Of String)(Function(s As String) s).ToList()
C#
propSorted = obj.Properties.Select(Function, ((Newtonsoft.Json.Linq.JProperty)(p)), p.Name).OrderBy(Of, String)[Function, ((string)(s)), s].ToList();
propSorted = obj.Properties.Select(Function, ((Newtonsoft.Json.Linq.JProperty)(p)), p.Name).OrderByDescending(Of, String)[Function, ((string)(s)), s].ToList();
2018-04-20 12:23 PM
I was able to reproduce the behavior too. I suspect 6.2.x didn't support OData for this specific call OR it was a defect fixed in 6.3.x.
When it fails in 6.2.x, I receive the following error:
[
{
"Links": [],
"RequestedObject": {},
"IsSuccessful": false,
"ValidationMessages": [
{
"Reason": "WebApi:WebApiOdataProcessExceptionReason",
"Severity": 3,
"MessageKey": "WebApi:WebApiOdataProcessException",
"Description": "Type 'Default.<>f__AnonymousType13_3OfGuid_String_Boolean' does not have a property 'Name'.",
"Location": -1,
"ErroredValue": null,
"Validator": "ArcherTech.Web.Api.OData.Processor.ODataProcessor, ArcherTech.Web.Api.OData, Version=6.2.0.1177, Culture=neutral, PublicKeyToken=null",
"XmlData": null,
"ResourcedMessage": "Exception processing OData query."
}
]
}
]
Here are a couple ways to help sort JSON objects based on a JSON property. First line of code is for Ascending.
VB.NET
propSorted = obj.Properties.Select(Function(p As Newtonsoft.Json.Linq.JProperty) p.Name).OrderBy(Of String)(Function(s As String) s).ToList()
propSorted = obj.Properties.Select(Function(p As Newtonsoft.Json.Linq.JProperty) p.Name).OrderByDescending(Of String)(Function(s As String) s).ToList()
C#
propSorted = obj.Properties.Select(Function, ((Newtonsoft.Json.Linq.JProperty)(p)), p.Name).OrderBy(Of, String)[Function, ((string)(s)), s].ToList();
propSorted = obj.Properties.Select(Function, ((Newtonsoft.Json.Linq.JProperty)(p)), p.Name).OrderByDescending(Of, String)[Function, ((string)(s)), s].ToList();
2018-04-20 12:44 PM
Thanks for confirming! If you are able to reproduce, then it's got to be related to the version, then.
2018-04-20 12:46 PM
Oh. Also, I'm trying to sort in a custom iview. So, no vb or c# here.