Although the IncludeAttachmentURLs
option is really not available via the client object model (at least in version 2013), you can still use the "good-old" SharePoint Web Services
to submit a CAML query including this option if you need to work from the client side, as described here:
$(document).ready(function() {
querySPWebServices();
});
function querySPWebServices() {
var soapEnv = "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \
<soapenv:Body> \
<GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
<listName>Projects</listName> \
<viewFields> \
<ViewFields> \
<FieldRef Name='Title' /> \
<FieldRef Name='Body' /> \
<FieldRef Name='ID' /> \
<FieldRef Name='Attachments' /> \
</ViewFields> \
</viewFields> \
<query> \
<Query /> \
</query> \
<queryOptions> \
<QueryOptions> \
<IncludeAttachmentUrls>TRUE</IncludeAttachmentUrls> \
</QueryOptions> \
</queryOptions> \
</GetListItems> \
</soapenv:Body> \
</soapenv:Envelope>";
$.ajax({
async: false,
url: "http://server.name.com/site/_vti_bin/lists.asmx",
type: "POST",
dataType: "xml",
data: soapEnv,
complete: processResult,
contentType: "text/xml; charset=\"utf-8\""
});
};
function processResult(xData, status) {
$(xData.responseXML).find("z\\:row").each(function() {
if ($(this).attr("ows_Attachments") != 0) {
var url = $(this).attr("ows_Attachments").replace(/#/g, "").split(';');
var ID = $(this).attr("ows_ID");
$("table.ms-listviewtable tr:has(td.ms-vb2)").find("td:first").filter(function() {
return $(this).text().toLowerCase() == ID;
}).html("<img src='" + url[1] + "' width=150 height=100 />");
};
});
};
Or you can use REST (as the title of your question suggest):
http://YourSharePoint/SubWeb/_api/Web/Lists/GetByTitle('YourList')/Items/?$expand=AttachmentFiles
Instead of CAML, add the condition, ordering and row limit attributes of your query via $filter
, $orderby
and $top
to the REST query as described here.