How to create a Page content and edit its body

[tab:Actions]

Requirements

 

In order to create a Page content the following conditions must be complied:

  • A business user must be used, and it needs the appropriate permission to create new content; therefore its credentials must be used (username and password must be used to perform login and obtain a valid token); a THRON application may be used to delete content, but only through SU web service which allows it to impersonate a business user (usually the owner of the application).

 

Creating a Page

 

If you want to create a new Page you have to use insert web service which is included within the content package of xadmin.

Parameters which must be included in the body of the request are:

  • contentType: PAGELET, to set the specific content type to be created
  • initAllLocales: by setting this parameter to "true" you will automatically fill basic information provided in the body for all the available languages.
  • basicInfoBylocale:
    • namethe title of the Page content.
    • descriptionthe description of the Page content.
    • prettyIdthe name of the content which will be used in URL address.
    • localelocale for basic metadata.
  • linkedCategoryId: the ids of the folder in which you want to publish the pagelet.
  • bufferthe body of the Page, base64 encoded.+
  • mimeType: text/html

 

NOTE: Please note that only one locale can be specified during the creation of the content. In order to set the content's basic information in all the available languages you will have to set the initAllLocales to "true". If you wish to edit these information in a specific language once the content has been created, you will have to use the updateContent4Locale web service, which is included within the contents package of xcontents.

Integration solutions offered by THRON automatically prevent the execution of any script included within the body for security reasons; hence any script included within the body of the page will be automatically removed.

 

Editing a Page

 

To edit the body of an existing Page you must use the web service updateSource which is included within the content package of xadmin

The first step is to recover the xcontentId of the content: it can be done using the findByProperties web service which is included within the content package of xcontents; further informations can be found here.

Once you know the xcontentId you can call the web service, including these parameters:

  • xcontentId: the ID of the Page to be updated
  • bufferthe body of the Page, base64 encoded.+

[/tab][tab:Code Samples] [dropdown:REST - CREATING A PAGE]

The headers that should be used for the request, which must be in POST are:

  • Content-Type: application / json
  • X-TokenId: XXXXX (using the token obtained through the login)

You can test this functionality in the Developer Center.

In the body of the request you can paste the following JSON, replacing required parameters:

{
    "param": {
        "contentType": "PAGELET",
        "contentOpt": {
            "initAllLocales": false,
            "basicInfoByLocale": [{
                "locale": "",
                "name": "",
                "description": "",
                "prettyId": ""
            }],
            "linkedCategoryIds": [
                ""
            ]
        },
        "sources": [{
                "raw": {
                    "buffer": "[ENTER PAGE BODY HERE, BASE64 ENCODED]",
                    "mimeType": "text/html"
            }
        }]
    },
    "silentMode": false
}    

Editing a page

The headers that should be used for the request, which must be in POST are:

  • Content-Type: application / json
  • X-TokenId: XXXXX (using the token obtained through the login)

You can test this functionality in the Developer Center.

In the body of the request you can paste the following JSON, replacing required parameters: 


    {
        "xcontentId": "",
        "param": {
            "sources": [{
                "raw": {
                    "buffer": "",
                    "mimeType": "text/html"
                }
            }],
            "preserveThumb": true
        },
        "silentMode": false
    }

[/dropdown][/tab]

Was this article helpful?
0 out of 0 found this helpful

Have any question?

Open a ticket
Comments