cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ericonline
Community Champion
Community Champion

Send an HTTP Request to Sharepoint: Filter OR?

Hello,

I can't find the correct syntax to $filter on multiple values. Anyone come across how to do this yet?

Example:

https://mycompany.sharepoint.com/sites/test/_api/web/lists/GetByTitle('BigLis')/items?$filter=ProjectNo eq '123', '141', '154'
I need the query to return records with ProjectNo 123, 141 or 154. 
Thank you!
2 ACCEPTED SOLUTIONS

Accepted Solutions

@ericonline 

 

Try

 

?$filter=ProjectNo eq '123' or ProjectNo eq '141' or ProjectNo eq '154'

'--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up

View solution in original post

 

Hi @ericonline ,

 

Please check this similar thread and see if it helps:

https://sharepoint.stackexchange.com/questions/163307/rest-api-filter-multiple-values

 

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
ericonline
Community Champion
Community Champion

I can get one to return with the following so I know the column is a String-type.

Its also a Lookup column, not sure if that matters...

https://mycompany.sharepoint.com/sites/test/_api/web/lists/GetByTitle('BigLis')/items?$filter=ProjectNo eq '123'

I've tried these variations to no avail...

filter=ProjectNo eq 15185 or 16236 or 16376
filter=ProjectNo eq '15185' or '16236' or '16376'
filter=ProjectNo eq '15185' or eq '16236' or eq '16376'
filter=ProjectNo eq '15185', '16236', '16376'

Error is "Bad Request"
 
"status": 400,
"message": "The query is not valid.\r\nclientRequestId: 30e70da3-c2c4-401a-8ab0-d7fb19129d79\r\nserviceRequestId: 1a550c9f-404e-9000-75b4-0f6e1eda22a7",
"source": "https://mycompany.sharepoint.com/sites/_api/web/lists/GetByTitle('BigList')/items?$filter=ProjectNo%20eq%20'15185'%20or%20'16236'%20or%20'16376'",
"errors": [
"-1",
"Microsoft.SharePoint.SPException"

@ericonline 

 

Try

 

?$filter=ProjectNo eq '123' or ProjectNo eq '141' or ProjectNo eq '154'

'--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up

 

Hi @ericonline ,

 

Please check this similar thread and see if it helps:

https://sharepoint.stackexchange.com/questions/163307/rest-api-filter-multiple-values

 

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you @RezaDorrani and @v-bacao-msft for the solution. It worked.

Something I noticed is that there is a limit to the length of the Sharepoint HTTP URL. I have to limit the number of characters to about ~2050 otherwise the query fails. 

Anyone else run into this?

And just another heads up... When you do exceed the ~2050 char limit in an HTTP Request, it fails with a Status 400 "Unauthorized" (which is not intuitive at all!)

 

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (3,148)