How to get records based on different Id's using rest API?
12,361
According to Use OData query operations in SharePoint REST requests the following OData query operators supported in the SharePoint REST service:
How to query multiple items via SharePoint REST
Since there is no in
operator in SharePoint REST, below are provided some equivalents:
Specify items explicitly using chained and
and or
operators:
/_api/web/lists/getByTitle(listTitle)/items?$filter=(ID eq 1) or (ID eq 2) or (ID eq 3)
Specify items limit in a query using top
operator:
/_api/web/lists/getByTitle(listTitle)/items?$top=3&$orderby=ID
Specify the range using lt
, le
, gt
, ge
operators:
/_api/web/lists/getByTitle(listTitle)/items?$filter=(ID ge 1) and (ID le 3)
Comments
-
Anish V almost 2 years
I need to get records from a list using
REST API
based on multiple Id's (Primary Key).Is it possible to pass multiple Id's in a single
REST API
call and get all the records in a single fetch ?Is there anything like "IN (1, 2, 3)" in
REST API
? -
Anish V about 10 yearsI'm using angularjs for code. But, I didn't properly get your answer. Can you please explain a bit ?
-
Eric Stein about 10 years@AnishV It's up to whoever wrote the API. If the API has some way of doing it, then you can. If it doesn't, you're out of luck. You'll need to go through the documentation or contact the vendor.
-
Anish V about 10 yearsThanks a lot for the detailed answer. :)
-
JLRishe about 2 yearsThis is a non-answer. Basically all you've said here is "yes, it's possible, if it's possible". The question is specifically about SharePoint's APIs, so a theoretical, noncommital answer is not merited.