Publishing an Event to an Event Channel
Function
This API is used to publish an event to an event channel. The API is only used for debugging purposes.
URI
POST /v1/{project_id}/channels/{channel_id}/events
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
Tenant resource space ID. |
channel_id |
Yes |
String |
ID of the event channel. |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
X-Auth-Token |
Yes |
String |
User token. The token can be obtained by calling the IAM API used to obtain a user token. The value of X-Subject-Token in the response header is the user token. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
events |
No |
Array of CloudEvents objects |
CloudEvents event format definition. For details, see https://github.com/cloudevents/spec/blob/v1.0.1/spec.md. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
id |
Yes |
String |
Event ID. The ID must be unique for the same event source. |
source |
Yes |
String |
Event source. The combination of source and id uniquely identifies an event. The URI-Reference format is used. For details, see https://tools.ietf.org/html/rfc3986#section-4.1. |
specversion |
Yes |
String |
CloudEvents protocol version. The format is major.minor. |
type |
Yes |
String |
Event type. |
datacontenttype |
No |
String |
Event content format. Events use the MIME format and comply with RFC 2046. For details, see https://tools.ietf.org/html/rfc2046. |
dataschema |
No |
String |
URI defined by the event content schema, which complies with RFC 3986. For details, see https://tools.ietf.org/html/rfc3986#section-4.3. |
data |
No |
Object |
Event payload content, which uses the format specified by the datacontenttype field. The content field complies with the description of the dataschema field. |
time |
No |
String |
UTC time when the event occurs. Events from the same source have the same format, which complies with RFC 3339. An example format is 2018-04-05T17:31:00Z. For details, see https://tools.ietf.org/html/rfc3339. |
subject |
No |
String |
Subject or object where the event occurs. |
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
X-Request-Id |
String |
This field is the request ID number for task tracking. Format is request_uuid-timestamp-hostname. |
Parameter |
Type |
Description |
---|---|---|
failed_count |
Integer |
Number of events that fail to be published. |
events |
Array of events objects |
Event list. |
Example Requests
Publish events to an event channel.
POST https://{endpoint}/v1/{project_id}/channels/{channel_id}/events { "events" : [ { "id" : "id", "source" : "source", "specversion" : "specversion", "type" : "blob_created" } ] }
Example Responses
Status code: 200
Information
{ "failed_count" : 0, "events" : [ { "event_id" : "r652c3f4e52c4eab89265b7a09ae6196" } ] }
Status Codes
Status Code |
Description |
---|---|
200 |
Information |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.