Very interesting question and good answers. I have tested it on a usual Tasks list and got it working after trial and error. The link provided above, Using CAML in REST requests, is good, although it contains syntax errors and unintroduced variables that makes it harder to try out the examples. Robert Kaucher has a working solution, even though it contained a little misspelling, that's why it caused a 500 error for me. I'd rather recommend to not to put the whole CAML query into a URL query string, it can stop working in an older IE browser due the url length restrictions. It is better to put the CAML query into a request body.
In my out-of-the-box Tasks list, the following CAML Query works:
<View>
<Query>
<Where>
<Or>
<Eq>
<FieldRef Name="AssignedTo" />
<Value Type="Integer"><UserID/></Value>
</Eq>
<Membership Type="CurrentUserGroups">
<FieldRef Name="AssignedTo" />
</Membership>
</Or>
</Where>
</Query>
</View>
Pay attention to <FieldRef Name="AssignedTo" />, not <FieldRef ID="Assigned To" />.
Here is the working jQuery.ajax-code:
var viewXml = "<View><Query><Where><Or><Eq><FieldRef Name='AssignedTo' /><Value Type='Integer'><UserID/></Value></Eq><Membership Type='CurrentUserGroups'><FieldRef Name='AssignedTo' /> </Membership></Or></Where></Query></View>";
$.ajax({
url: "/_api/web/lists/getbytitle('Tasks')/getitems",
method: "POST",
data: "{ 'query' : {'__metadata': { 'type': 'SP.CamlQuery' }, \"ViewXml\": \""
+ viewXml + "\" }}",
headers: {
"X-RequestDigest": $("#__REQUESTDIGEST").val(),
"Accept": "application/json; odata=verbose",
"content-type": "application/json; odata=verbose"
}
});
If you prefer to use SP.RequestExecutor and be independent of jQuery, just replace data
with body
in the request options. Make sure you have the SP.RequestExecutor.js loaded into your page first:
executor.executeAsync({
url: "/_api/web/lists/getbytitle('Tasks')/getitems",
method: "POST",
body: "{ 'query' : {'__metadata': { 'type': 'SP.CamlQuery' }, \"ViewXml\": \"" + viewXml + "\" }}",
headers: {
"X-RequestDigest": $("#__REQUESTDIGEST").val(),
"Accept": "application/json; odata=verbose",
"content-type": "application/json; odata=verbose"
}
});
SP.RequestExecutor will make it easier to rewrite the code to an app and use it in a cross-domain scenario.
To try this request I have used PostMan.

And Developer Tools in my browser, to see results without writing ajax callbacks.
