0

I'm working on a SharePoint instance which consists of one site and 4 sub-sites. Each one of those sub-sites contains multiple files, separated into multiple folders.

What I'm trying to do is write a REST API call which will search through all of the files based on their properties and return those which match a certain property (eg. Project name: "Project1").

What's the best way to accomplish this?

1

CAML Query. Here's an example that shows the calling syntax, you just need to figure out the appropriate CAML.

var viewXml = { ViewXml: "<View>" +
    "<Query>" +
    "<Where><Eq>" +
    "<FieldRef Name='Category' LookupId='True' />" +
    "<Value Type='Lookup'>1</Value>" +
    "</Eq></Where>" +
    "</Query>" +
    "</View>"
}

var call = jQuery.ajax({
    url: _spPageContextInfo.webAbsoluteUrl +
        "/_api/Web/Lists/getByTitle('Products')/GetItems(query=@v1)?" +
        @v1=" + JSON.stringify(viewXml),
    type: "POST",
    dataType: "json",
    headers: {
        Accept: "application/json;odata=verbose",
        "X-RequestDigest": jQuery("#__REQUESTDIGEST").val()
    }
});
  • Hi Rob, looks like your solution is the way to go, however the application in question and sharepoint are on different domains so the ajax call is not getting through. I'm currently looking for a server-side solution, any tips would be appreciated. – Dr. Greenthumb Oct 29 '15 at 20:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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