EntryPublishAction
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
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| Uid | string? | No | null | UID of the publish rule. Sent as uid. |
| Action | string? | No | null | publish, unpublish, or both. Sent as action. |
| Status | int | No | 0 | Request status code. Sent as status. |
| Notify | bool | No | true | Notifies the approvers. Sent as notify. |
| Comment | string? | No | null | Comment for the approver. Sent as comment. |
Class-Level Notes
Status values.
- The Content Management API (CMA) reference lists three values for status. See Request/Accept/Reject Entry Publish Request.
- 0: approval requested.
- 1: approval accepted.
- -1: approval rejected.
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}");
}