Data Management (DMS) allows you to use custom webhook URLs as a notification method in addition to text messages, emails, DingTalk notifications, and DingTalk chatbot messages.
Configure a webhook URL as a notification method
Configure notification methods in the DMS console. In the Modify notification method dialog box, enter a webhook URL in the webhook field and select webhook next to Notification method.
For more information, see Configure personal information and notification methods.
Request for an event notification
When notifications are generated in DMS, DMS sends the notifications to the webhook URL that you specify. This section describes the content of a POST request.
Request header
DMS-Event: Message Hook
Request parameters
Parameter | Type | Description |
submitterUid | String | The ID of the account that submits the task. |
submitterName | String | The name of the account that submits the task. |
category | String | The module to which the task belongs, such as Tickets, Task Orchestration, or Data Warehouse Development. |
module | String | The type of business, such as permission application, data change, schema design, or data export. |
event | String | The event that is triggered by the status of the task, such as pending approval, success, or failure. |
taskId | String | The ID of the ticket or task flow. |
taskName | String | The name of the task. |
eventTime | String | The time when the event occurs. |
message | String | The preset message in DMS. |
targetUsers | Array | The recipient to receive the notification. You can specify one or more recipients. |
receivers | Array | The recipient that actually receives the notification. You can specify one or more recipients. If you do not set the Notification method parameter, the recipients cannot receive the notification. |
uid | String | The ID of the recipient. When you specify a recipient, you must provide the ID of the recipient. |
name | String | The name of the recipient. When you specify a recipient, you must provide the name of the recipient. |
signatureMethod | String | The signature method that is required when a custom webhook URL is used as a notification method. Valid values:
|
signatureText | String | The digital signature that is calculated by using the HMAC_SHA1 algorithm based on the Webhook URL, password, and message event. Example: 4mOdwflN1CgxxxxxxxuipuCYYWk= . |
Sample request
{
"messageEvent":{
"submitterName":"xxx",
"submitterUid":"167382665015xxxx",
"category":"Tickets",
"event":"Success",
"eventTime":1625630049930,
"message":"[DMS] Webhook test, code: 144619 ",
"Module":"Data change"
"receivers":[{"name":"xxx1","uid":"167382665015xxxx"},{"name":"xxx2","uid":"167382665016xxxx"}],
"targetUsers":[{"name":"xxx1","uid":"167382665015xxxx"},{"name":"xxx2","uid":"167382665016xxxx"}],
"taskName":"Webhook test"
},
"signatureMethod":"HMAC_SHA1",
"signatureText":"4mOdwflN1Cg5NdM2XPuipuCYYWk="
}
Sample responses
{"root":"","success":true} // The notification is sent.
{"root":"error message","success":false} // The notification fails to be sent.
Example
You can create an echo script to test a webhook URL and view the notification that is sent by using the webhook URL.
- Save the following sample code as a script named print_http_body.rb.
require 'webrick' server = WEBrick::HTTPServer.new(:Port => ARGV.first) server.mount_proc '/' do |req, res| puts req.body end trap 'INT' do server.shutdown end server.start
- Select a port that is not used, such as port 8000. Run the script:
ruby print_http_body.rb 8000
. - In the DMS console, configure a webhook URL as a notification method, such as
http://my.host:8000/
. For more information, see Configure personal information and notification methods.If a server is configured to use Basic Authentication over the HTTP protocol, you can access the server by using a webhook URL that contains the username and password. Sample webhook URL:http://userName:password@my.host:8080/project/test-job
- In the Modify notification method dialog box, click Test on the right of the webhook field. DMS sends a notification to the webhook URL that you specify.
The following code provides an example on the notification sent by DMS:
{ "messageEvent":{ "submitterName":"xxx", "submitterUid":"167382665015xxxx", "category":"Tickets", "event":"Success", "eventTime":1625630049930, "message":"[DMS] Webhook test, code: 144619 ", "Module":"Data change" "receivers":[{"name":"xxx1","uid":"167382665015xxxx"}], "targetUsers":[{"name":"xxx1","uid":"167382665015xxxx"}], "taskName":"Webhook test" }, "signatureMethod":"HMAC_SHA1", "signatureText":"4mOdwflN1Cg5NdM2XPuipuCYYWk=" } 127.0.0.1 - - [20/Apr/2021:20:07:47 CST] "POST / HTTP/1.1" 200 0