Home > Software engineering >  Rest api filter by field equals null in Angular
Rest api filter by field equals null in Angular

Time:11-14

I got an Angular app that connects to a REST API (in C#).

I am trying to send a filter to the GetAll endPoint, so that I get all the elements of a certain type in a table, except those that have a null category.

I have tried this:

let filter = (type eq 'A')`;
filter  = ` and (categoryId eq '$NULL')`;

But while this works perfectly, the above code it returns zero results.

let filter = (type eq 'A')`;

So I guess the syntax I found in internet for filtering nulls in rest is not correct (or I am applying it wrong), or it maybe that null filtering is not supported?

CodePudding user response:

It's not clear how do you call the Rest API but the filter query to return data without category should look like

let filter = `type eq 'A' and categoryId eq null`;
  • Related