Inside our sharepoint 2013 on-premises, i have the following code inside our server side item-added event receiver:-
public override void ItemAdded(SPItemEventProperties properties)
{
base.ItemAdded(properties);
PublishingSite pSite = new PublishingSite(properties.Site);
SPContentType ctype = pSite.ContentTypes[contenttype];
PageLayoutCollection pageLayouts = pSite.GetPageLayouts(ctype, true);
PageLayout pageLayout = pageLayouts[pagelayout];
PublishingWeb pWeb = PublishingWeb.GetPublishingWeb(properties.Web);
PublishingPageCollection pPages = pWeb.GetPublishingPages();
PublishingPage pPage = pPages.Add(newPageName + ".aspx", pageLayout);
//code goes here
the above code will create an enterprise wiki page which is linked to the related PageLayout/ContentType.
now i want to create an equivalent remote event receiver for the above code, so i did the following:-
private void HandleItemAdded(SPRemoteEventProperties properties)
{
using (ClientContext clientContext =
TokenHelper.CreateRemoteEventReceiverClientContext(properties))
{
if (clientContext != null)
{
try
{
PublishingSite pSite = new PublishingSite(clientContext);
SPContentType ctype = Site.ContentTypes[contenttype];
but the above code is raising errors on the 2 lines:-
PublishingSite pSite = new PublishingSite(clientContext);
SPContentType ctype = Site.ContentTypes[contenttype];
Errors:-
Error1 There is no argument given that corresponds to the required formal parameter 'objectPath' of 'PublishingSite.PublishingSite(ClientRuntimeContext, ObjectPath)'
Error2 The type or namespace name 'SPContentType' could not be found (are you missing a using directive or an assembly reference?)
so can anyone advice how i can covert the above server-side code to sharepoint client side object module?