Resorting to asking a question on here as I cant seem to find anyone else who is trying to access the Target Audiences field with the REST API.
If I try and pull out all the items in my list using:
/_api/lists/getbytitle('xxxx')/items
The definition returned doesnt contain the Target Audiences field, even though its part of the content type associated with my list and I've added an item to the list and populated this field. If I try and grab this specific field:
/_api/lists/getbytitle('xxxx')/items?$select=Audience
It says The field or property 'Audience' does not exist. Even though it is there on the content type and list.
I chucked in a quick bit of server side code on page load and I can get the field using server side code:
SPWeb web = SPContext.Current.Web;
SPList list = web.Lists.TryGetList(xxxx);
if (list != null)
{
foreach (SPListItem item in list.Items)
{
var audiences = item["Target Audiences"];
}
}
But does anyone know why it isnt accessible with client side code? I'm creating a custom admin screen for a list which has a Target Audience field so I need to be able to pull the value back and set the value as well, but it's like the client side doesnt think it exists, when it clearly does and can be accessed on the server side