web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

$Filter in odata

(1) ShareShare
ReportReport
Posted on by 1,833
Hi,

can i use filter with expand?

So calling odata with GET for this URL works: 
{{resource}}/data/XX?cross-company=true&$filter=CustAccount eq 'ABC' and dataAreaId eq 'USMF' and Id eq '123'&$select=Id,Status&$expand=YY($select=LineId, ZDate)

Now if i want to filter on LineId, i get this error: 
No HTTP resource was found that matches the request
 
{{resource}}/data/XX?cross-company=true&$filter=CustAccount eq 'ABC' and dataAreaId eq 'USMF' and Id eq '123'&$select=Id,Status&$expand=YY($select=LineId, ZDate&$filter=LineId eq 'www')



I also tried this but got this error
{{resource}}/data/XX?cross-company=true&$filter=CustAccount eq 'ABC' and dataAreaId eq 'USMF' and Id eq '123'&$select=Id,Status&$expand=YY($select=LineId, ZDate;$filter=LineId eq 'www')
{
    "error": {
        "code": "",
        "message": "An error has occurred.",
        "innererror": {
            "message": "Nested query options in $expand are not supported.",
            "type": "System.Net.WebException",
            "stacktrace": "   at Microsoft.Dynamics.Platform.Integration.Services.OData.Query.QueryableExtensions.ValidateNestedQueryOptionsforExpand(SelectExpandClause selectExpandClause)\r\n   at Microsoft.Dynamics.Platform.Integration.Services.OData.Query.QueryableExtensions.ApplyQueryOptions(IQueryable queryable, HttpRequestMessage request, ODataQueryOptions queryOptions, Boolean isCollection)\r\n   at Microsoft.Dynamics.Platform.Integration.Services.OData.AxODataController.Get()"
        }
    }
}
Categories:
I have the same question (0)
  • Sohaib Cheema Profile Picture
    47,802 User Group Leader on at
    $Filter in odata
    Hi @..
    The error message is coming from a standard DLL that exists in the application (Microsoft.Dynamics.Platform.Integration.Services.OData)
     

    You can read the error message saying: "Nested query options in $expand are not supported."
     
    You can make two separate calls. One call to get the record from the XX entity.A second call to get the related records by directly querying the YY entity. This approach allows you to apply as many filters as needed on the YY entity.
     
    Another option is to create a custom entity for YY (with pre-set filters defined in the entity's query), say YY_Custom, and then call it along with XX using $expand.
     
    Another option is to build a single custom entity that merges data from XX, YY, and any other necessary sources or tables.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Sohaib Cheema Profile Picture

Sohaib Cheema 756 User Group Leader

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 629 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 514 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans