Hi All,
I am getting below issue while accessing External Lists of top level site (Host web) in App part using JavaScript Client object model.
System.UnauthorizedAccessException
Access denied. You do not have permission to perform this action or access this resource.
Observations
From App Part
1. Same code if I execute from App part accessing any other default lists it is working fine.
From Top Level Site page
2.Same code if I place it Content editor Web part of Top level site page (after removing AppContextSite related code) and try accessing External list it is working fine.
3.Same code if I place it Content editor Web part of subsite site page (after removing AppContextSite related code) and try accessing External list it is working fine.
Not able to understand the exact reason why is it failing when we try to access external list from AppPart
any thoughts on this would be really helpful.
Code Sample which I tried
function retrieveBCSListItems() { var hostWebUrl = decodeURIComponent(manageQueryStringParameter('SPHostUrl')); var AppWebUrl = decodeURIComponent(manageQueryStringParameter('SPAppWebUrl')); // var clientContext = new SP.ClientContext(hostWebUrl); var clientContext = SP.ClientContext.get_current(); var listSiteCtx = new SP.AppContextSite(clientContext, hostWebUrl); var listSiteWeb = listSiteCtx.get_web(); var oList = listSiteWeb.get_lists().getByTitle("Personaldetails"); var camlQuery = new SP.CamlQuery(); camlQuery.set_viewXml("<View>" +"<Query>" +"<Where><Eq>" +"<FieldRef Name='FirstName' />" +"<Value Type='Text'>Raghu</Value>" +"</Eq></Where>" +"</Query>" +"</View>"); collListItem = oList.getItems(camlQuery); clientContext.load(collListItem); clientContext.executeQueryAsync(onQuerySucceeded, onQueryFailed); }
ragava_28