Vasu
Vasu

Reputation: 129

Add filter to my odata is not working

Add filter to my odata is not working.

here is my api:

http://appsworldapiclient.azurewebsites.net/breeze/ClientCursor/GetContactDetails?companyId=4

I have to apply filter $filter=startswith(FirstName, 'A') eq true

If i dont have companyId=4 its working fine, but without that my api wont work. Can anyone help on this?

Upvotes: 1

Views: 150

Answers (1)

Sam Xu
Sam Xu

Reputation: 3380

Actually, I don't think I really understand what you're asking.

From your End point Uri, it seems that you want to call an operation (function/action) named GetContactDetails with a parameter as companyId=4.

Next, you mentioned that you have to put the $filter clause. It seems that you want to do as follows:

http://appsworldapiclient.azurewebsites.net/breeze/ClientCursor/GetContactDetails?companyId=4&$filter=startswith(FirstName, 'A') eq true

If it's true, the above Uri template does not follow up the OData spec.

So, as I think,

  1. if GetContactDetails is an unbound operation, you can do it as: ~/ClientCursor/GetContactDetails(companyId=4)?&$filter=startswith(FirstName, 'A') eq true

  2. If GetContactDetails is an entity set and companyId is the key, you can simply do as: ~/ClientCursor/GetContactDetails(4)?&$filter=startswith(FirstName, 'A') eq true

Of course, if you can show us more codes or metadata, it can help us to understand clearer.

Upvotes: 1

Related Questions