Can we retrieve the TypeName of a web part using CSOM?

  • What would be the reason I get Access denied during the web service call? I have the highest permissions possible in the environment. If it makes a difference, I'm calling this from an auto-hosted SharePoint 2013 App. – user21884 Jan 10 '14 at 14:43
  • I personally used server-side CSOM instead of Vadim's code so haven't checked the code. However, you could try to call other services. I think there should not be any specific permissions needed for this service in particular. – thomius Jan 11 '14 at 15:56

It doesn't seem possible to retrieve all the web part properties (like TypeName) via CSOM

But it could be performed via WebPartPagesWebService SharePoint Web Service as demonstrated below:

function getWebPartProperties(pageUrl,completeFn,errorFn)
    var soapEnv =
        '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">  \
            <soap:Body>  \
                <GetWebPartProperties2 xmlns="http://microsoft.com/sharepoint/webpartpages">  \
                    <pageUrl>' + pageUrl + '</pageUrl>   \
                    <storage>Shared</storage>   \
                    <behavior>Version3</behavior>   \
                </GetWebPartProperties2>  \
            </soap:Body>   \

        url: _spPageContextInfo.webAbsoluteUrl + "/_vti_bin/WebPartPages.asmx",
        type: "POST",
        dataType: "xml",
        data: soapEnv,
        complete: completeFn,
        error: errorFn,
        contentType: "text/xml; charset=\"utf-8\""

$(function() {
            $(xhr.responseXML).find("WebPart").each(function() {
                var wpTypeName = $(this).find('type').attr('name'); //get Web Part TypeName

  • Btw does this or something like this work for publishing pages? – thomius Jan 4 '14 at 13:59
  • I had a chance to verify it for publishing pages and it works for me – Vadim Gremyachev Jan 4 '14 at 14:05
  • 1
    oh, apparently the error was not due to publishing pages but web part types. Tasks web part returns only one property "Cannot import this Web Part" apparently.. – thomius Jan 4 '14 at 14:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.