I am trying to use the OData $expand
query option to fetch the Title of a SharePoint User Field. The field name is, Author (Created By). However, on using the $expand
option, I am getting the following error,
The $expand query is not valid for field 'Author'.
Following is the URL that I am using to fetch the data.
https://appUrl/_api/Sp.AppContextSite(@target)/Web/Lists(guid'guid')/items?$select=Number1,Author/Title&$expand=Author/ID&@target='targetSiteUrl'
Interestingly, if I use the following URL from a SharePoint Content Editor Web Part then everything is working fine!
http://targetSiteUrl/_api/Web/Lists(guid'guid')/items?$select=Number1,Author/Title&$expand=Author/ID
So, my question is, am I doing something wrong or we cannot use $expand
from within the scope of a SharePoint App? As of now, it works fine directly from the site but not from the add-in.
$expand=Author
as well as$expand=Author/ID
None of them worked. Getting the same error!