Forum Discussion
Uploading Sharepoint Page with Graph getting checked out
I am trying to use the API to upload pages, and it is kind of working in the sense that I can upload them, but the problem I am running into is that the pages are not visible after uploading, I have to go to this menu under library settings and manually take ownership of the pages uploaded using Graph:
I am calling this endpoint to do so : https://graph.microsoft.com/beta/sites/{{site_id}}/pages
I know there is another endpoint to publish the page, but that is not the idea. I want it uploaded and visible to me in the site's page list but not published.
I am following the docs to upload it and as I found on another threads of people having the same problem I have selected this in the site settings:
I am sending json's like the next one without all the placeholders:
{
"@odata.type": "#microsoft.graph.sitePage",
"description": "This plain text should also be easy to get",
"eTag": "\"{placeholder},placeholder\"",
"id": "placeholder",
"lastModifiedDateTime": "2023-10-04T15:16:47Z",
"name": "aitorTestName.aspx",
"webUrl": "SitePages/aitorTestName.aspx",
"title": "aitorTestName",
"pageLayout": "article",
"thumbnailWebUrl": "placeholderURL",
"promotionKind": "page",
"showComments": true,
"showRecommendedPages": false,
"contentType": {
"id": "placeholder",
"name": "Site Page"
},
"createdBy": {
"user": {
"displayName": "placeholder"
}
},
"lastModifiedBy": {
"user": {
"displayName": "placeholder"
}
},
"parentReference": {
"siteId": "placeholder"
},
"publishingState": {
"level": "published",
"versionId": "3.0"
},
"reactions": {
"commentCount": 2
},
"titleArea": {
"enableGradientEffect": true,
"layout": "colorBlock",
"showAuthor": true,
"showPublishedDate": false,
"showTextBlockAboveTitle": true,
"textAboveTitle": "testing text above title",
"textAlignment": "left",
"title": "aitorTest",
"imageSourceType": 4,
"authorByline": [
"i:0#.f|membership|placeholder"
],
"hasTitleBeenCommitted": true,
"isDecorative": true,
"authors": [
{
"id": "i:0#.f|membership|placeholder",
"upn": "placeholder",
"email": "",
"name": "placeholder",
"role": ""
}
],
"serverProcessedContent": {
"htmlStrings": [],
"searchablePlainTexts": [],
"links": [],
"imageSources": []
}
},
"canvasLayout": {
"horizontalSections": [
{
"layout": "oneColumn",
"id": "1",
"emphasis": "none",
"columns": [
{
"id": "1",
"width": 12,
"webparts": [
{
"id": "placeholder",
"innerHtml": "<p>This plain text should also be easy to get</p><p> </p>"
}
]
}
]
},
{
"layout": "oneColumn",
"id": "2",
"emphasis": "none",
"columns": [
{
"id": "1",
"width": 12,
"webparts": [
{
"id": "placeholder",
"webPartType": "placeholder",
"data": {
"audiences": [],
"dataVersion": "1.0",
"description": "Display a list from this site.",
"title": "List",
"properties": {
"isDocumentLibrary": false,
"selectedListId": "placeholder",
"selectedListUrl": "/sites/placeholder/Lists/Dashboard",
"webRelativeListUrl": "/Lists/Dashboard",
"webpartHeightKey": 4
},
"serverProcessedContent": {
"htmlStrings": [],
"searchablePlainTexts": [
{
"key": "listTitle",
"value": "Dashboard will be here for testing purposes"
}
],
"links": [],
"imageSources": []
}
}
}
]
}
]
}
]
}
}
I have also tried messing with the publishing state but no luck.
I also know there is another endpoint to Check In files, and I was attempting to use it but in my site when I attempt to get the driveId in which pages are stored, it does not appear any, I only get drives of Shared Documents and other drives I manually created, but under none of those my pages are stored.
Can anybody help me find a way in which I can upload a page to my site using that Graph endpoint and not having to manually go to the checked out files and one by one start taking ownership of them to be able to see them in my site page's list?