Share via

Sharepoint save as draft

Twinkle Chatterjee 21 Reputation points
2021-04-21T09:20:51.55+00:00

hello,
My application has a feature where the user can write a blog and save is as a draft. currently in site pages, the draft is saved as a minor version 0.1 . when the user goes and edits the draft story again and saves it as a draft again, it should ideally save as 0,2 but it still saves as 0.1 version. is there a way to achieve this so that when the same story is saved for a second time, it saves as 0.2 at the back end?
the rest api i have used is

${this.pageContext.site.absoluteUrl}/${subsite}/_api/sitepages/pages(${this.pageContext.listItem.id})/SavePageAsDraft;

Microsoft 365 and Office | SharePoint | For business | Windows
0 comments No comments

1 answer

Sort by: Most helpful
  1. ZhengyuGuo 10,591 Reputation points Moderator
    2021-04-22T04:56:53.713+00:00

    Hi @Twinkle Chatterjee ,

    "SavePageAsDraft" endpoint won't override the minor version, it just make the site page exist the edit mode and save the current changes for the page into draft.

    In fact, when user Click "Edit" button in the page, the page has already generate a new minor version, you can check this point in the UI.

    If want to use Rest API to generate the new minor version, you could do a check out action for the page, then it will also have the new minor version, as before editing, the page need to check out firstly, in the same time, the new minor version created:

    /_api/web/GetFileByServerRelativeUrl('/SitePages/TestPage1.aspx')/CheckOut()  
    

    Thanks
    Best Regards


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.