Search code examples
restgetodataexact-online

How to filter Exact Online accounts on their classification code?


I am trying to make a list of how much accounts have a certain classification1 code (which currently ranges from 1 to 7).

when accessing the API (which makes use of OData) I get the following error:

No property 'Code' exists in type 'System.Nullable`1[[System.Guid, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=*********]]' at position 16.

My url looks like this:

https://start.exactonline.nl/api/v1/*/crm/Accounts?$inlinecount=allpages&$top=0

but when I add a filter it gives the error.

https://start.exactonline.nl/api/v1/*/crm/Accounts?$inlinecount=allpages&$top=0&$filter=Classification1/Code eq '1'

The API I access is found here:

https://start.exactonline.nl/docs/HlpRestAPIResourcesDetails.aspx?id=9 https://start.exactonline.nl/docs/HlpRestAPIResourcesDetails.aspx?id=7

Is there an easier was to receive all the different count values or to fix the filter?


Solution

  • Unfortunately that is not possible. Classification1 is a Guid, not an object with the properties of a classification.

    If you want to filter on the classification code, you first have to retrieve the Guid of the classification, and then filter on the Guid.

    So first:

    /api/v1/{division}/crm/AccountClassifications?$filter=Code eq 'yourCode'&$select=ID
    

    And then, using the result of the previous call:

    /api/v1/{division}/crm/Accounts?$filter=Classification1 eq guid'the-guid-you-retrieved'