1

When using the REST API which approach is the most effective to retrieve items from a list?

Is it the filter method or the CAML query? Both works prefectly fine, but I would suspect the query method to be more effective since it's "asking" the server to return items which matches rather than getting all items and then aplies a filter. But I could very well be wrong.

Added (29/12):

When I say filter approach i mean like this:

_api/web/lists(guid'[List GUID]')/items?$Select=Id&$filter=(Aktiv%20eq%201)

And when I say query i mean like this:

/_api/web/lists(guid'[List GUID]')/GetItems(query=@v1)?@v1={"ViewXml":"<View><Query><Where><Eq><FieldRef Name="Aktiv" /><Value Type="Number">1</Value></Eq></Where></Query></view>"}

Both returns all items which is in fact active (marked with a 1). The filter is a HTTP Get call and the query is a simple HTTP Post call.

2
  • Functionality-wise this answer describes a difference between CAML and filter.
    – moe
    Dec 28, 2017 at 12:48
  • Thanks - but that doesn't get me any closer to which performancewise is the better option :)
    – Morten K
    Dec 28, 2017 at 12:51

1 Answer 1

-1

The basic difference between rest API and CAML query filter depends on your need. if you are working on third-party preferable REST API. it is very easy to implement with less knowledge of SharePoint.

CAML query needs some deep knowledge as well as request header and much more stuff. it's good for batch processing. when you want to load more than one list it will trigger the server only one time while rest is taking as same as no. list. in this case, performance will matter.

the filter is working same as per my knowledge. in both cases.

8
  • I'm not sure I'm following you here. I'm specifically talking of the case where using the REST API to fetch items from a list. I know I can use both CAML query and filtering - but which of the two in that given scenario is the better option from a server load/speed/effectiveness perspective?
    – Morten K
    Dec 29, 2017 at 7:13
  • when your items are less than 5000 and no. of the list is one: both taking the same time. and if no. of the list is more than one than CSOM is better in all ways.
    – Negi Rox
    Dec 29, 2017 at 7:23
  • I don't see how the number of lists come into play. You cannot query multiple lists with a single REST call regardless if you use the filter approach or the query approach. I will update my original question to reflect what I'm talking about.
    – Morten K
    Dec 29, 2017 at 11:37
  • I agreed, but I am telling if you need multiple List then CAML query with JSOM is better.
    – Negi Rox
    Dec 29, 2017 at 12:51
  • That's not really related to the question I'm asking.
    – Morten K
    Dec 29, 2017 at 13:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.