GameBuilder
GameBuilder

Reputation: 1189

ODATA : Issue with "OR" Operator

I am trying to create a ODATA Url with OR Operator.

I have two URLs which works fine and has a filter like shown below

CorporateAccountCollection?$filter=(Phone eq '%2B33 123456789' or Phone eq '%2B33 1 23 45 67 89')

and

 CorporateAccountCollection?$filter=(Mobile eq '%2B33 123456789' or Mobile eq '%2B33 1 23 45 67 89')

I tried to concatenate above 2 filter with another OR Operator , which doesnt work

/CorporateAccountCollection?$filter=((Phone eq '%2B33 123456789' or Phone eq '%2B33 1 23 45 67 89') or (Mobile eq '%2B33 123456789' or Mobile eq '%2B33 1 23 45 67 89'))

Can anybody tell me what i am doing wrong?

Thank you Regards

Prat

Upvotes: 2

Views: 11996

Answers (1)

Chris Schaller
Chris Schaller

Reputation: 16689

Because your conditions are simply OR'd together, you do not use all those brackets to enforce execution. (The brackets shouldn't matter, but depending on the query parser that the API is using, double brackets can sometimes be mistakenly be interpreted as implicit AND

Your query should be:

CorporateAccountCollection?$filter=Phone eq '%2B33 123456789' or Phone eq '%2B33 1 23 45 67 89' or Mobile eq '%2B33 123456789' or Mobile eq '%2B33 1 23 45 67 89'

or if your like the outer brackets:

CorporateAccountCollection?$filter=(Phone eq '%2B33 123456789' or Phone eq '%2B33 1 23 45 67 89' or Mobile eq '%2B33 123456789' or Mobile eq '%2B33 1 23 45 67 89')

there are no error messages in this scenario because the criteria is simply filtering out the rows that you are expecting to see.
There is no error parsing your query, which is where error messages would normally come from.

If that does not work, please provide the raw outputs from your two queries that do work so that we can help determine what else might be the problem.

usually these issues come down to specific nounces with the strings and values you are comparing.

Upvotes: 2

Related Questions