Commands client

The SDK provides a Commands client to execute commands that are publicly registered in Sitecore Content Hub.

Execute commands

The following information is needed to execute a command:

  • Command namespace

  • Command name

  • Command arguments (depending on the command)

To execute a command through the SDK:

RequestResponse

await MClient.Commands.ExecuteCommandAsync(namespace, name, args);

Supported commands

Here is a list of available commands.

Namespace

Command name

Arguments

external.action

external.action

RequestResponse

new JObject(
    new JProperty("entity_id", <entity id>),
    new JProperty("action_id", <action id>),
    new JProperty("properties", new JArray()),
    new JProperty("relations", new JArray()),
    new JProperty("action_execution_source", "ExternalAction"),
    new JProperty("extra_data", new JObject())

m.security

applyuserrole

RequestResponse

new JObject(
        new JProperty("user_id", <user id>),
        new JProperty("role", <role>),
        new JProperty("target_id",  <target id>))

m.asset

setmaster

RequestResponse

new JObject(
        new JProperty("new_master_id", <new master id>),
        new JProperty("entity_id", <entity id>),
        new JProperty("master_relation", <master relation>))

Examples

external.action command

RequestResponse

using Newtonsoft.Json.Linq;

JObject args = new JObject(
    new JProperty("entity_id", 30897),
    new JProperty("action_id", 12345),
    new JProperty("properties", new JArray()),
    new JProperty("relations", new JArray()),
    new JProperty("action_execution_source", "ExternalAction"),
    new JProperty("extra_data", new JObject(new JProperty("culture", "en-US"))));

await MClient.Commands.ExecuteCommandAsync("external.action", "external.action", args).ConfigureAwait(false);

Do you have some feedback for us?

If you have suggestions for improving this article,