All Products
Search
Document Center

Data Management:Send notifications by using a custom webhook URL

更新時間:Sep 13, 2024

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.

Modify notification method dialog box

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

ParameterTypeDescription
submitterUidStringThe ID of the account that submits the task.
submitterNameStringThe name of the account that submits the task.
categoryStringThe module to which the task belongs, such as Tickets, Task Orchestration, or Data Warehouse Development.
moduleStringThe type of business, such as permission application, data change, schema design, or data export.
eventStringThe event that is triggered by the status of the task, such as pending approval, success, or failure.
taskIdStringThe ID of the ticket or task flow.
taskNameStringThe name of the task.
eventTimeStringThe time when the event occurs.
messageStringThe preset message in DMS.
targetUsersArrayThe recipient to receive the notification. You can specify one or more recipients.
receiversArrayThe 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.
uidStringThe ID of the recipient. When you specify a recipient, you must provide the ID of the recipient.
nameStringThe name of the recipient. When you specify a recipient, you must provide the name of the recipient.
signatureMethodStringThe signature method that is required when a custom webhook URL is used as a notification method. Valid values:
  • None: No signature is used. This is the default value.
  • HMAC_SHA1: The Hashed Message Authentication Code Secure Hash Algorithm 1 (HMAC_SHA1) is used.
signatureTextStringThe 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.

  1. 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
  2. Select a port that is not used, such as port 8000. Run the script: ruby print_http_body.rb 8000.
  3. 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
  4. 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