msgraph-sdk-java icon indicating copy to clipboard operation
msgraph-sdk-java copied to clipboard

Not able to publish a SharePoint page, so created page is stuck in "Checked out"

Open jdimeo opened this issue 1 year ago • 1 comments

Expected behavior

Based on the API documentation here: https://learn.microsoft.com/en-us/graph/api/sitepage-publish?view=graph-rest-1.0

I would expect this code to compile:

client.sites().bySiteId(ms.getSiteId()).pages()
	.byBaseSitePageId("0eb44212-1667-41bb-b200-d41689ffddc8")
	.graphSitePage()
	.publish();

Actual behavior

I can only do a GET from the graphSitePage point in the SDK, there is no publish() method.

Steps to reproduce the behavior

Use the POST to create a site page and then try to publish it via the SDK. This is important because I used a app client secret, not myself, so I can't "see" the page in the Sharepoint UI when I log in as myself.

jdimeo avatar Apr 25 '24 04:04 jdimeo

Hacktacular workaround that shockingly works:

client.sites().bySiteId(ms.getSiteId()).pages().withUrl(
	client.getRequestAdapter().getBaseUrl() + "/sites/" + ms.getSiteId() + "/pages/0eb44212-1667-41bb-b200-d41689ffddc8/microsoft.graph.sitePage/publish"
).post(new BaseSitePage());

jdimeo avatar Apr 25 '24 04:04 jdimeo