The WebAPI macro is the new macro (available as of Smartsite 8.1) to add or edit content items and replaces the cmsupdate macro (although it will continue to work for backwards compatibility). The macro connects directly to the manager's WebAPI.

The manager's WebAPI requires authentication and executes the specified method on behalf of the authenticated user. Therefore, the authenticated user must have access to the item(s) which is/are in scope for the invoked method.

Naturally, this user must have access to the content item and/or it's parent, the content item(s) must not be locked or have an active workflow assignment to another person or group, etcetera. The same access controls applied by edit item, in fact.
And of course, this user must have access to the WebAPI (the mgr-WEBAPIACCESS privilege). 

To specifiy on behalf of which user the WebAPI macro should call the managers' WebAPI, you can specify an username or -id using the macro parameter username or userid respectively. When neither of these are specified, the WebAPI macro will use the current UserProfile, if any, which must not be the guest user. Once the user is determined, internal logic is used to generate an access token and the manager's WebAPI is called using this access token.

In short, when the WebAPI macro is called from a restricted page, there's no need to specify an username or userid. A major advantage compared to the cmsupdate macro in earlier versions of Smartsite is also that you no longer have to specify a password via a macro parameter.
(As of Smartsite 8.1, the cmsupdate macro uses the same technology to authenticate to the WebAPI.)

Syntax

Smartsite SXML CopyCode image Copy Code
<se:webapi />

Parameters

Name Data Type Properties Description
Payload String - Sets the input data for the savecmsitem method.
Method String - Sets the method to invoke on the manager's WebAPI, e.g. savecmsitem or loaditemversion.
UserName String - Sets the name of the user to connect to the WebAPI (optional).
UserId Integer - Sets the id of the user to connect to the WebAPI (optional).
ItemNumber Integer - Sets the itemnumber (applicable for the methods loaditemversion and togglefolder).
ItemNumbers String - Sets the itemnumbers (applicable for the "bulk" methods: activateitems, deactivateitems, archiveitems and deleteitems). 
Url String - Sets the url to the managers' WebAPI. Defaults to the WebApiAddress app setting, and when that setting is not present defaults to "http://localhost/mgr/webapi.net". 

Payload

The payload parameter sets the inputdata for the savecmsitem method. When invoking this method, payload is mandatory. The payload must be specified as xml, in a format similar to the xml used (for example) by "edit item". (See the example below). When debugging has been enabled within the manager, you can view the xml format being used within edit item using the View Instance debug option.

Method

The method parameter sets the method to invoke on the manager's WebAPI. The following methods are available:

  • loaditemversion
  • savecmsitem
  • togglefolder
  • activateitems
  • deactivateitems
  • archiveitems
  • deleteitems

As mentioned above, the payload parameter is required when the savecmsitem method is called. The itemnumber parameter is required when the loaditemversion or the togglefolder method is called.

For the other methods (activateitems, deactivateitems, archiveitems and deleteitems), the itemnumbers parameter is required.This must be a comma-separated list of itemnumbers or -codes.

Expand image Examples

SXML