Using IN operator OData 4.0 "Bad Request" FetchXML Builder xrmtoolbox

169 Views Asked by At

By using FetchXML Builder in Xrmtoolbox I have an OData 4.0 string:

.../contacts?$filter=(searchable eq true) 
             or (contains(firstname, '%25firstName%25)' 
             or contains(lastname, '%25lastName%25') 
             or Microsoft.Dynamics.CRM.In(PropertyName= '_accountid_value', PropertyValues=['00000000-0000-0000-0000-000000000000','c198b30d-8d4e-eb11-a812-000d3ab5acdf','6c9caaac-a755-eb11-a812-0022489b9c9c']) 
             or Microsoft.Dynamics.CRM.In(PropertyName= 'contactid', PropertyValues=['00000000-0000-0000-0000-000000000000','30262317-0a83-eb11-a812-000d3ab02826']))

I have manually changed "and" to "or" in the query, so I am afraid it is just a small detail that I have missed. However, I have never used the IN operator with this tool before and am therefore worried it might be an issue with the way I use it/I have done something wrongly.

How do I know there is an issue with the string? The image below shows the code in C# when I am trying to fetch the data. This is where I can't get through because I get "Bad request" from the HTTPClient.GetAsync method. I know that the method call is not the problem because I do this in several other places, and can therefore only assume it is the OData string. I have also got "Bad request" before and fixed it making the OData string correct.

enter image description here

Has anyone else had this issue or know what is wrong with the OData string that I am overlooking?

Edit: I checked the docs linked by @PanagiotisKanavos. Unfortunately this also gives my "Bad request".

".../contacts?$filter=(searchable eq true) or (contains(firstname, '%25Mat%25)' or contains(lastname, '%25son%25') or _accountid_value in ('c198b30d-8d4e-eb11-a812-000d3ab5acdf','6c9caaac-a755-eb11-a812-0022489b9c9c') or contactid in ('30262317-0a83-eb11-a812-000d3ab02826'))"
0

There are 0 best solutions below