I found SPWeb.SiteLogoUrl and expected this property in CSOM and REST. But I didn't find it. How can I get a SiteLogoUrl using CSOM or REST?
SP.js
Microsoft.SharePoint.Client.dll
I found SPWeb.SiteLogoUrl and expected this property in CSOM and REST. But I didn't find it. How can I get a SiteLogoUrl using CSOM or REST?
SP.js
Microsoft.SharePoint.Client.dll
It was moved to the POST request that SharePoint creates while redirecting via appredirect.aspx. So, the only one way to get Site Logo Url is to handle appredirect POST request.
To initiate redirect you should use this code snippet:
Response.Redirect(TokenHelper.GetAppContextTokenRequestUrl(sharePointHostUrl, Server.UrlEncode(targetUrl)));
ContextToken, SiteLogo, Url, Title and so on can be found in the POST FormData.
According to UserVoice driving improvements to SharePoint API Microsoft released SharePoint 2013 and SharePoint Online solution packs that contains the following change to the existing API:
Web
object exposesAlternateCssUrl
property via CSOM (.Net, REST, JS)
Alternatively you could install the latest versions of SharePoint Server 2013 Client Components SDK or SharePoint Online Client Components SDK
Examples
How to update Web.AlternateCssUrl
property using CSOM:
using (var ctx = new ClientContext(webUri))
{
ctx.Web.AlternateCssUrl = "/SiteAssets/Contoso.css";
ctx.Web.Update();
ctx.ExecuteQuery();
}
How to get Web.AlternateCssUrl
property using REST:
$.getJSON(_spPageContextInfo.webAbsoluteUrl + "/_api/web")
.done(function(data)
{
console.log(data.AlternateCssUrl);
})
.fail(
function(error){
console.log(JSON.stringify(error));
});