pnp / pnp/pnpframework

Web API not able to create the pages in sharepoint tenant

Open
#537 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
259
Forks
161
Avg merge
10h 33m
Merged PRs (30d)
1

Description

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" };
    }

`

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the ValuesController example and trace the call to ExecuteQueryRetry followed by AddClientSidePage. Compare this Web API flow with the console application where the same code works, then verify that page2.Save() completes and the page with its requested sections is created without the browser remaining in a loading state.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.