0
votes

I'm using the built in Web Service API in Sitefinity 9.1 which is following OData standards.

I have a URL like this to receive the JSON in the format I would like:

/api/stories/storyitems?$select=Title,Summary,ageranges,UrlName,topics,ButtonText

I have a JSON from that service that looks like this:

"value": [
    {
    "Title": "Developing Reading Skills",
    "Summary": "Lorem ipsum dolor sit amet",
    "ageranges": [
        "3ca54b5b-06ab-63fa-8375-ff00000b3273"
    ],
    "topics": [
        "f0a84b5b-06ab-63fa-8375-ff00000b3273",
        "efa84b5b-06ab-63fa-8375-ff00000b3273"
    ],
    "ButtonText": "Learn More",
    "UrlName": "developing-reading-skills"
    }
    ....
]

This works great, but I am having a problem with filtering this service by ageranges or topics.

I've tried a few different solutions. This seems to be the standard OData way to filter but this throws an error. I'm not sure if this is a problem with my formatting, or the Sitefinity implementation. Can someone confirm?

/api/stories/storyitems?$filter=any(ageranges eq '3ca54b5b-06ab-63fa-8375-ff00000b3273')&$select=Title,Summary,ageranges,UrlName,topics,ButtonText

Here's the error I get back in the JSON:

{
    "error": {
        "code": "",
        "message": "An error has occurred."
    }
}

Thanks!

2

2 Answers

1
votes

try:

?$filter=ageranges/any(a: a eq 'xxxx')
1
votes

I was directed to this article that indicated this is the proper way:

/api/stories/storyitems?$filter=Category/any(s:s eq d81e4d00-afe6-60df-84cd-ff0000aaa3eb)&$select=Title,Summary,ageranges,UrlName,topics,ButtonText