Creates one or more event targets for an event rule.

URI

/openapi/createTargets

Request parameters

Parameter Type Required Example Description
EventBusName String Yes default The name of the event bus.For more information, see Limits.
RuleName String Yes myRule2 The name of the event rule.For more information, see Limits.
Targets List<Target> Yes The event targets that you want to create. For more information, see Limits.
Id String Yes target5 The custom ID of the event target.
Type String Yes acs.fc.function The type of the event target.
Endpoint String Yes acs:fc:cn-hangzhou:123456789098****:services/guide.LATEST/functions/HelloFC The endpoint of the event target.
PushRetryStrategy String Yes BACKOFF_RETRY The retry policy that is used to push the event. Valid values:
  • BACKOFF_RETRY: backoff retry. The request can be retried up to three times. The interval between two consecutive retries is a random value between 10 and 20 seconds.
  • EXPONENTIAL_DECAY_RETRY: exponential decay retry. The request can be retried up to 176 times. The interval between two consecutive retries exponentially increases to 512 seconds, and the total retry time is one day. The specific retry intervals are 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 512, ..., and 512 seconds, including a maximum of one hundred and sixty-seven 512 seconds in total.
ParamList List<Param> Yes The parameters that the event passes.
resourceKey String Yes body The resource key of the transformed event.For more information, see Event target parameters.
form String Yes TEMPLATE The transformation method.For more information, see Event target parameters.
value String Yes
{\"key\"=\"value\"}
The event value to be transformed.
template String No The value of ${key} is ${value}! The format of the template.

Response parameters

Parameter Type Example Description
ErrorEntriesCount Int
  • 0
  • 1
The number of event bodies that failed to be processed. Valid values:
  • 0: No event bodies failed to be processed.
  • An integer other than 0: indicates the number of event bodies that failed to be processed.
ErrorEntries List
  • N/A
  • [
        {
            "ErrorCode":"EventRuleTargetIdDuplicate",
            "ErrorMessage":"The id of event target is duplicate! ",
            "EntryId":"target5"
        }
    ]
The information about the event body that failed to be processed.
ErrorCode String EventRuleTargetIdDuplicate The error code returned.
ErrorMessage String The id of event target is duplicate! The error message returned.
EntryId String target5 The ID of the event body that failed to be processed.

Examples

Sample requests

POST /openapi/createTargets HTTP/1.1
Host: 123456789098****.eventbridge.cn-hangzhou.aliyuncs.com
Date: Sat, 18 Apr 2020 05:30:41 GMT
x-eventbridge-version: 2020-04-01
Authorization: acs vZ3VL0SuJdHi****:Jo2PbTj******zYAYoYslKLvWzg=
Content-Type: application/json;charset=UTF-8
Content-Length: 26

{
    "EventBusName":"default",
    "RuleName":"myRule2",
    "Targets":[
        {
            "Id":"target5",
            "Type":"acs.fc.function",
            "Endpoint":"acs:fc:cn-hangzhou:123456789098****:services/guide.LATEST/functions/HelloFC",
            "PushRetryStrategy":"BACKOFF_RETRY",
            "ParamList":[
                {
                    "resourceKey":"serviceName",
                    "form":"CONSTANT",
                    "value":"guide"
                },
                {
                    "resourceKey":"functionName",
                    "form":"CONSTANT",
                    "value":"HelloFC"
                },
                {
                    "resourceKey":"body",
                    "form":"TEMPLATE",
                    "value":"{\"key\"=\"value\"}",
                    "template":"The value of ${key} is ${value}!"
                }
            ]
        }
    ]
}

Sample success response

HTTP/1.1 200 OK
Server: AliyunEventBridge
Connection: keep-alive
Content-Type: application/json;charset=utf-8
Content-Length: 79
x-eventbridge-request-id: 5E9A908133324571D800****
Date: Sat, 18 Apr 2020 05:30:41 GMT

{
    "errorEntriesCount":0,
    "errorEntries":[

    ]
}

Sample error response

HTTP/1.1 200 OK
Server: AliyunEventBridge
Connection: keep-alive
Content-Type: application/json;charset=utf-8
Content-Length: 79
x-eventbridge-request-id: 5E9A908133324571D800****
Date: Sat, 18 Apr 2020 05:30:41 GMT

{
    "errorEntriesCount":1,
    "errorEntries":[
    {
        "ErrorCode":"EventRuleTargetIdDuplicate",
        "ErrorMessage":"The id of event target is duplicate! ",
        "EntryId":"target5"
    }
]
}