pnpframework icon indicating copy to clipboard operation
pnpframework copied to clipboard

Web API not able to create the pages in sharepoint tenant

Open rajeshpatil74 opened this issue 4 years ago • 2 comments

Following code from WebAPI is not able to create a new web page in sharepoint site .... but same code works with console application. With latestes Pnp.framework 1.7 it stops executing at AddClientSidePage

`
public class ValuesController : ApiController { // GET api/values public IEnumerable Get() { string url = "https://svtech09.sharepoint.com/sites/SVSite001"; var autheticationManager = new AuthenticationManager(); var page = "mypage.aspx";

        using (var ctx = autheticationManager.GetACSAppOnlyContext(url, "client-id", "secret-key"))
        {
            Web web = ctx.Web;
            ctx.Load(web.Lists);
            ctx.Load(web, w => w.SupportedUILanguageIds);
            ctx.Load(web);

            ctx.ExecuteQueryRetry();
            //Create the Page
            var page2 = ctx.Web.AddClientSidePage(page, true);

            // Not executing above statement ... no exception also....Browser page shows loading indicator in header .....


            page2.AddSection(CanvasSectionTemplate.ThreeColumn, 5);
            page2.AddSection(CanvasSectionTemplate.TwoColumn, 10);
            page2.Save();
        }
        return new string[] { "value1", "value2" };
    }

`

rajeshpatil74 avatar Nov 29 '21 13:11 rajeshpatil74

@rajeshpatil74 : can you provide a stack trace? What Azure function version are you using?

jansenbe avatar Dec 02 '21 17:12 jansenbe

@rajeshpatil74 : can you provide a stack trace? What Azure function version are you using?

There is no stack trace / No exception. The code doesn't return back even after waiting for 2-3 min with Pnp.Framework 1.7.0.

With older pnp framework (SharePointPnPCoreOnline) which is deprecated now it is working.

rajeshpatil74 avatar Dec 18 '21 15:12 rajeshpatil74