Page lifecycle operations

Get the state of a page

The GetState method returns the current version of the page and other information denoting whether editing or adding new components on the page is allowed.

To get the state of a page, execute a GET request to the following endpoint:

{baseurl}/api/default/pages({page_id})/Default.GetState

Where {page_id} is the ID of the page whose status you want to get.

Sample request

GET http://mysite.com/api/default/pages(917ef635-3099-4a8e-bbd0-298191a4b547)/Default.GetState

Sample response

Status code: 200 OK
JSON
{
    "@odata.context": "http://mysite.com/sf/system/$metadata#Telerik.Sitefinity.Renderer.Editor.EditorState",
    "Version": 264,
    "HasChanged": false,
    "AddAllowed": false,
    "EditAllowed": false,
    "SegmentId": "00000000-0000-0000-0000-000000000000",
    "WidgetState": [
        {
            "Key": "e5e9efa8-479e-4263-9343-1e84be54b0ce",
            "Name": "Section",
            "DeleteAllowed": false,
            "EditAllowed": false,
            "MoveAllowed": false,
            "LabelTooltip": "INHERITED FROM TEMPLATE",
            "IsPersonalized": false,
            "WidgetSegmentId": null
        },
        {
            "Key": "06f84d12-a7e5-40ef-ad9c-4ecf4555b58a",
            "Name": "Section",
            "DeleteAllowed": false,
            "EditAllowed": false,
            "MoveAllowed": false,
            "LabelTooltip": "INHERITED FROM TEMPLATE",
            "IsPersonalized": false,
            "WidgetSegmentId": null
        },
        {
            "Key": "56781528-1fb5-4c30-b690-ea2225580001",
            "Name": "ContentBlock",
            "DeleteAllowed": false,
            "EditAllowed": false,
            "MoveAllowed": false,
            "LabelTooltip": "INHERITED FROM TEMPLATE",
            "IsPersonalized": false,
            "WidgetSegmentId": null
        }
    ]
}

In this response the version is 264, which denotes that the page has been published or saved as draft more than 200 times.

The AddAllowed and EditAllowed properties are false, because the page was locked when the request was made.

Lock a page

It is important to lock the page before modifying it, because this way other users can see that this page is being edited by someone else and they will see a message that it is currently not available for modifications on their end.

PREREQUISITES: To lock a page, you must know its version. To get the version of page, use Get the state of a page procedure above.

To lock a page, execute a POST request to the following endpoint:

{baseurl}/api/default/pages({page_id})/Default.Lock

Where {page_id} is the ID of the page which you want to lock.

Sample request

POST http://mysite.com/api/default/pages(917ef635-3099-4a8e-bbd0-298191a4b547)/Default.Lock

Request body
JSON
{
    "state": {
        "Version": 11
    }
}

In this request, you must send the page version. The version number is incremented by 1 every time a change to the state of the page is made. For example, when you publish a page or add a widget to it.

Sample response

Status code: 204 No Content

No response body

Unlock а page

Unlocking a page is an operation that changes the state of a page from locked to unlocked. After you have finished editing a page, you should unlock it.

To unlock a page, execute a POST request to the following endpoint:

{baseurl}/api/default/pages({page_id})/Default.Unlock

Where {page_id} is the ID of the page you want to unlock.

Sample request

POST http://mysite.com/api/default/pages(917ef635-3099-4a8e-bbd0-298191a4b547)/Default.Unlock

Sample response

Status code: 204 No Content

No response body

Publish a page

For any changes to the layout of a page to take effect, you must publish the page.

To publish a page, execute a POST request to the following endpoint:

{baseurl}/api/default/pages({page_id})/operation

Where {page_id} is the ID of the page you want to publish.

In response body, you must specify the type of the operation – in this example, Publish.

Sample request

POST http://mysite.com/api/default/pages/(917ef635-3099-4a8e-bbd0-298191a4b547)/operation

Request body
JSON
{
    "action": "Publish",
    "actionParameters": {
    }
}

In this request, the action is set to Publish. You can also specify other actions, such as Schedule.

Sample response

Status code: 200 OK
JSON
{
  "Success": true,
  "Title": null,
  "AvailableActions": null,
  "UndoOperation": null,
  "Message": "Page has been published successfully.",
  "MultipleItemsMessage": null,
  "SucceededItemsIds": null,
  "FailedItemsIds": null,
  "Type": 0
}

Schedule a page to be published or unpublished

For any changes to the layout of a page to take effect, you must publish the page. You can also schedule a page to be published on a specific date or unpublished on a specific date, or both.

To schedule a page for publishing or unpublishing, execute a POST request to the following endpoint:

{baseurl}/api/default/pages({page_id})/operation

Where {page_id} is the ID of the page which you want to publish or unpublish.

In response body, you must specify the type of the operation – in this example, Schedule. You must also specify the date when you want to publish or unpublish a page, or, in this case, both.

Sample request

POST http://mysite.com/api/default/pages/(917ef635-3099-4a8e-bbd0-298191a4b547)/operation

Request body
JSON
{
   "action":"Schedule",
   "actionParameters":{
      "PublicationDate":"2021-09-02T11:35:40.140Z",
      "ExpirationDate":"2021-09-28T21:00:00.000Z"
   }
}

In this request, the action is set to Schedule. You can also specify which date the page should be published on and which date it should be unpublished on.

Sample response

Status code: 200 OK
JSON
{
  "Success": true,
  "Title": null,
  "AvailableActions": null,
  "UndoOperation": null,
  "Message": null,
  "MultipleItemsMessage": null,
  "SucceededItemsIds": null,
  "FailedItemsIds": null,
  "Type": 0
}
Want to learn more?
Enhance your Sitefinity skills by enrolling in free training sessions. Become Sitefinity certified through Progress Education Community to strengthen your professional credentials.