EntryPublishAction

View as Markdown

EntryPublishAction

EntryPublishAction holds the publish rule details that the PublishRequest and PublishRequestAsync methods of Entry send.

When to Use This Class: Use this class when a publish rule requires approval, to request approval for an entry or to accept or reject a request.

Conceptual Role: Acts as the data model that the SDK sends under the workflow.publishing_rule key of a publish request.

Returns: EntryPublishAction. The publish request details of an entry.

Properties

NameTypeRequiredDefaultDescription
Uidstring?NonullUID of the publish rule. Sent as uid.
Actionstring?Nonullpublish, unpublish, or both. Sent as action.
StatusintNo0Request status code. Sent as status.
NotifyboolNotrueNotifies the approvers. Sent as notify.
Commentstring?NonullComment for the approver. Sent as comment.

Class-Level Notes

Status values.

What the SDK sends.

  • Status and Notify are value types, so the SDK always sends them. Without changes, a request carries status 0 and notify true, which requests approval.
  • The SDK sends Uid, Action, and Comment when they are not null, and checks none of them.

Method Index

EntryPublishAction has no methods. Set its properties and pass it to the PublishRequest method of Entry.

Class-Level Snippet

The snippet below requests approval to publish an entry under a publish rule.

using System;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models;

ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");

EntryPublishAction publishAction = new EntryPublishAction
{
    Uid = "<PUBLISH_RULE_UID>",
    Action = "publish",
    Status = 0,
    Notify = true,
    Comment = "Please approve the launch article"
};

try
{
    ContentstackResponse response = client.Stack("<API_KEY>").ContentType("<CONTENT_TYPE_UID>").Entry("<ENTRY_UID>").PublishRequest(publishAction);
    Console.WriteLine(response.OpenJsonObjectResponse()["notice"]);
}
catch (ContentstackErrorException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.ErrorMessage}");
}