跳到主要内容

自定义 Webhooks

Postman 的自定义 webhook 集成使你能够自动化你最喜爱的应用程序和服务之间的工作流程,以获取通知、同步文件、收集数据等。它提供具有你可以实施的预定义流程的服务。

你可以使用 Postman 配置自定义 webhook 以发送事件,例如监控结果或团队和特定于集合的活动提要,或者备份你的 Postman 集合。

启用静态 IP 支持

如果你的网络在防火墙后面,你将需要使用静态 IP 地址来启用收集备份到自定义域上的自定义 webhook。

联系你的 IT 团队,将以下静态 IP 列入防火墙中的白名单,以启用对 webhook 的集合备份:

  • 美国东部:3.212.102.200

将此 IP 地址列入许可名单后,对自定义 webhook 的调用将能够连接到你的网络并允许 webhook 按预期工作。

配置自定义 webhook

  1. 集成 页面上,从集成列表中搜索并选择 Webhooks。

    自定义网络钩子

    集成的页面为每种类型的自定义 webhook 提供了选择。如果可用,你可以查看先前为所选集成配置的集成。

    Webhooks 集成选择

  2. 选择 Webhook 类型旁边的添加集成以配置你的集成。针对你要添加的 webhook 类型执行下面相关部分中的步骤。

创建集成后,你可以查看你创建的集成以及你的团队创建的其他活动集成:

配置的集成

将 Postman 集合的更新发送到自定义 webhook

  1. Webhooks Integrations 页面中,在**Backup a collection旁边,选择Add Integration**
  2. 在添加集成页面中:
    • 输入集成的昵称。
    • 在 Choose Collection下,选择你要为其发送更新的集合。
    • 输入你的 webhook 负载将发送到的 webhook URL。
  3. 选择添加集成

示例集合备份架构

以下是备份集合 webhook 的架构:

{
"$schema": "http://json-schema.org/draft-04/schema#",
"definitions": {},
"id": "http://example.com/example.json",
"properties": {
"collection": {
"id": "/properties/collection",
"properties": {},
"type": "object"
}
},
"type": "object"
}

将监控结果发送到自定义 webhook

Postman 监视器使你能够按计划运行你的集合,而无需任何人工干预。通过自定义 webhook,你可以通过连接到其他可用服务来使用这些结果。

  1. Webhooks Integrations 页面中,在**Post monitoring results旁边,选择Add Integration**
  2. 在添加集成页面中:
    • 输入集成的昵称。
    • 选择包含要发送到自定义 webhook 的监视器的工作空间。
    • 选择你要发送的显示器。
    • 输入你的 webhook 负载将发送到的 webhook URL。
  3. 选择添加集成

你还可以配置高级选项,以便在监控器运行完成时或出现三个故障时提醒你,并且在这些故障后的第一个监控器运行成功完成。

每当你的监视器运行时,结果都会发布到你的 webhook。

示例监视器结果模式

以下是监控运行结果的架构:

{
"$schema": "http://json-schema.org/draft-04/schema#",
"definitions": {},
"id": "http://example.com/example.json",
"properties": {
"collection_name": {
"id": "/properties/collection_name",
"type": "string"
},
"collection_uid": {
"id": "/properties/collection_uid",
"type": "string"
},
"environment_name": {
"id": "/properties/environment_name",
"type": "string"
},
"environment_uid": {
"id": "/properties/environment_uid",
"type": "string"
},
"metrics": {
"id": "/properties/metrics",
"properties": {
"errors":
"id": "/properties/metrics/properties/errors",
"type": "integer"
},
"failedTests": {
"id": "/properties/metrics/properties/failedTests",
"type": "integer"
},
"passedTests": {
"id": "/properties/metrics/properties/passedTests",
"type": "integer"
},
"requestCount": {
"id": "/properties/metrics/properties/requestCount",
"type": "integer"
},
"totalLatency": {
"id": "/properties/metrics/properties/totalLatency",
"type": "integer"
},
"warnings": {
"id": "/properties/metrics/properties/warnings",
"type": "integer"
}
},
"type": "object"
},
"monitor_name": {
"id": "/properties/monitor_name",
"type": "string"
},
"monitor_uid": {
"id": "/properties/monitor_uid",
"type": "string"
},
"user_id": {
"id": "/properties/user_id",
"type": "string"
},
"user_name": {
"id": "/properties/user_name",
"type": "string"
}
},
"type": "object"
}

将团队活动提要发送到自定义 webhook

活动提要是你可以跟踪对你的集合和你的团队所做的更改的地方。

  1. Webhooks Integrations 页面中,在**Post team activity旁边,选择Add Integration**
  2. 在添加集成页面中:
    • 输入集成的昵称。
    • 输入 webhook URL 以将团队更新发送到此特定 URL。
  3. 选择添加集成

示例团队活动模式

以下是团队活动 webhook 的架构:

{
"$schema": "http://json-schema.org/draft-04/schema#",
"definitions": {},
"id": "http://example.com/example.json",
"properties": {
"action": {
"id": "/properties/action",
"type": "string"
},
"collection_name": {
"id": "/properties/collection_name",
"type": "string"
},
"collection_uid": {
"id": "/properties/collection_uid",
"type": "string"
},
"message": {
"id": "/properties/message",
"type": "string"
},
"model": {
"id": "/properties/model",
"type": "string"
},
"model_name": {
"id": "/properties/model_name",
"type": "string"
},
"model_uid": {
"id": "/properties/model_uid",
"type": "string"
},
"user_id": {
"id": "/properties/user_id",
"type": "string"
},
"user_name": {
"id": "/properties/user_name",
"type": "string"
}
},
"type": "object"
}