Skip to content
This repository has been archived by the owner on Jun 17, 2024. It is now read-only.

How to upload page layouts with content type and associated content type? #7

Closed
SamiSaves opened this issue Mar 30, 2017 · 3 comments
Closed
Labels

Comments

@SamiSaves
Copy link

Hi!

I am having problems while trying to upload page layouts with metadata. I need to upload a page layout and set its content type to page layout and then set its Associated content type to article page. I am trying to set ContentTypeId to Page Layout id but that doesn't seem to do anything. And when I try to add PublishingAssociatedContentType it just crashes with this error

Unable to update metadata of the file
Unhandled rejection StatusCodeError: 400 - {"error":{"code":"-1, Microsoft.SharePoint.Client.InvalidClientQueryException","message":{"lang":"en-US","value":"The property 'PublishingAssociatedContentType' does not exist o
n type 'SP.Data.OData__x005f_catalogs_x002f_masterpageItem'. Make sure to only use property names that are defined by the type."}}}

Someone tried the same thing and posted an issue of it to the gulp-spsync. wictorwilen/gulp-spsync#11

This is my current metadata that I am trying to set:

{
        "name": "Test.aspx",
        "metadata": {
            "__metadata": {
                "type": "SP.Data.OData__x005f_catalogs_x002f_masterpageItem"
            },
            "Title": "Publishing article page",
            "MasterPageDescription": "Publishing article page.",
            "ContentTypeId": "0x01010007FF3E057FA8AB4AA42FCB67B453FFC100E214EEE741181F4E9F7ACC43278EE811",
            "PublishingAssociatedContentType": ";#Article Page;#0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D;#" 
}

Do you know if it is possible to upload page layouts and set the correct metadata to them with this library?

@estruyf
Copy link
Owner

estruyf commented Mar 31, 2017

It appears that this field is not exposed via the API. So that means that you cannot access it.

Also did a test on my side, but get the same result.

Also tried to retrieve it from an existing PL: https://tenant.sharepoint.com/sites/demo/_api/web/lists/getbytitle('Master Page Gallery')/items(87)?$select=PublishingAssociatedContentType

Which returns: The field or property 'PublishingAssociatedContentType' does not exist.

@SamiSaves
Copy link
Author

Thanks for testing it! Then it would seem that it is not possible to do this with the current REST API. We have to wait until Microsoft decides to expose it to the rest api.

I didin't check this throughly, but it might be possible to achieve this via JSOM https://msdn.microsoft.com/en-us/library/office/jj994682.aspx. Do you know if it is possible to use JSOM with gulp? If not I might try to achieve this with executing Javascript from developer console in our tenant after uploading the files, or alternatively set up PnP powershell to change the content types.

@madenorth
Copy link

I tried for a while to get this working but it just won't. The property isn't in the type SP.Data.OData__x005f_catalogs_x002f_masterpageItem and there isn't a definition accessible for the correct content type. We only have a few content types so they set them manually after the initial deployment.

@estruyf estruyf closed this as completed Apr 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants