Client Library - Filter By OR Condition

Hello,
I’m using the Squidex Client Library to query contents and would like to make use of the OData or Json filter functionality.

I have a schema with a Name and Id fields and would like to filter values of Id field using OR operator. In the GetAsync method of ContentClients, I’m passing ContentQuery object with Filter property value as below.

data/Id/iv eq '12345' or data/Id/iv eq '12345'

But it results in an error saying “The app name or schema name or entity doesn’t exist” with 400 status code.

So, I thought of trying the Json filter option and set the below value to the property JsonQuery of ContentQuery object. But that too resulted in the same error as above.

JsonQuery = new
    {
        filter = new
        {
            or = Ids.Take(10).Select(x => new 
            {
                path = "data.Id.iv",
                op = "eq",
                value = $"{x}"
            }).ToArray()
        }
    }

NOTE : Ids is just a List that holds all the values that I like to filter on.

Can you let me know what I’m doing wrong here ?

This should work. It seems you have a general issue with the config. I don’t see how a query can produce a 400 o 404 response.

Hello,
Not sure of which config you’re referring to. Can you explain ? Below is the exception that I receive from the library.

When modify the query to not to have OR operator and point to one particular Id, it returns the output as expected.

What I meant: Is the problem the filter or does it also not work without no filtering at all. How have you configured your client ID and secret?

It works without filtering as well as with simple filtering. I see the error when I try to use the OR operator.

Below filtering works just fine.

JsonQuery = new
    {
        filter = new
        {
            path = "data.Id.iv",
                op = "eq",
                value = $"{Ids[0]}"
           
        }
    }

I have to try to reproduce that.

Thank you. I will wait to hear from you.

I have added your case to the API tests and it works fine for me: https://github.com/Squidex/squidex/blob/master/backend/tools/TestSuite/TestSuite.ApiTests/ContentQueryTests.cs#L427

Strange that it works for you.

Can you try the same for a referenced field ? I’m trying to query against a referenced field but I didn’t think that matters.

I do not have a setup for that, and I am pretty sure it does not matter.

Does the below stack trace tell you anything about what is going wrong ? Also, the error message, “The app, schema or entity does not exist.” is not helping either.

   at Squidex.ClientLibrary.Utils.SquidexClientBase.<EnsureResponseIsValidAsync>d__12.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Squidex.ClientLibrary.Utils.SquidexClientBase.<RequestJsonAsync>d__10`1.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Program.<<Main>$>d__0.MoveNext() in C:\Users\narayanasamys\source\repos\SquidexUserDataCorrection\SquidexUserDataCorrection\Program.cs:line 45

Perhaps you do not have permissions for all references or the app or something like that?

I do have all the required permissions. Also, the query works when I don’t have OR condition.
I guess, I’ve to troubleshoot further at my end.

I was looking into the ClientLibrary and I think this line is throwing the error. But why we’re getting 404,I’m not sure. I will look further.

Yes, this is “normal”, you have already said that you receive a 404. You will also get a 404 when you do not have permission for an app, btw.

I do have all the required permission. The query fails when I try with OR operator. May be one of the Id that I’m passing doesn’t exist and that results in 404 ? Not sure. I’m going to look into the logs and provide you the details.

Do you have a script or something like that? If you can, provide me a backup of your database and a sample to reproduce it. Then I can have a closer look.