Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/rest/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在DocuSign PowerForms/Templates上配置eventNotification 问题:_Python_Rest_Docusignapi - Fatal编程技术网

Python 如何在DocuSign PowerForms/Templates上配置eventNotification 问题:

Python 如何在DocuSign PowerForms/Templates上配置eventNotification 问题:,python,rest,docusignapi,Python,Rest,Docusignapi,我希望使用webhook配置由单个DocuSign模板/PowerForm创建的所有文档,这样我就不需要获取完整的文档。我读了很多书,想知道这在docusignapi中是否可行 背景 我有一个自助式豁免文档:用户导航到URL,填写他们的联系信息(即定义收件人角色),并期望他们完成的豁免被链接系统识别 我有一个在a中使用的:用户导航到PowerForm的URL,PowerForm将允许他们从相关模板创建一个新信封 我希望此设置创建的文档在完成时通过标准自动通知HTTPS端点 尝试的解决方案 该方法

我希望使用webhook配置由单个DocuSign模板/PowerForm创建的所有文档,这样我就不需要获取完整的文档。我读了很多书,想知道这在docusignapi中是否可行

背景 我有一个自助式豁免文档:用户导航到URL,填写他们的联系信息(即定义收件人角色),并期望他们完成的豁免被链接系统识别

我有一个在a中使用的:用户导航到PowerForm的URL,PowerForm将允许他们从相关模板创建一个新信封

我希望此设置创建的文档在完成时通过标准自动通知HTTPS端点

尝试的解决方案 该方法(
POST/v2/accounts/{accountId}/envelopes
)接受可用于配置Webhook的
eventNotification
参数。本文很好地介绍了这个端点的用法。这将解决我的问题,如果我通过API请求创建每个信封,但我喜欢PowerForm附带的可复制可访问URL的简单性

虽然没有文档记录,但是(
PUT/v2/accounts/{accountId}/envelopes/{envelopeId}
)可能支持在已经创建的信封上配置通知。我可以重复使用我的模板,更新正在进行的信封上的通知,并处理完成的信封,但这并不比轮询更好

我浏览了,特别是和类别,但我没有看到任何明显的方式来配置这两种资源,以便在创建的信封上设置
eventNotification

下面是我所做的一些API探索的快速代码转储:

#!/usr/bin/env python3
import requests


username = 'user@example.com'
password = 'some-sensitive-password'
integrator_key = 'abcdef01-2345-6789-0abcdef0123456789'


# Authenticate to the DocuSign API, get the base URL for subsequent requests
authenticate_str = (
    "<DocuSignCredentials>"
    "<Username>" + username + "</Username>"
    "<Password>" + password + "</Password>"
    "<IntegratorKey>" + integrator_key + "</IntegratorKey>"
    "</DocuSignCredentials>"
)
headers = {'X-DocuSign-Authentication': authenticate_str,
           'Accept': 'application/json'}
api_base = 'https://demo.docusign.net/restapi/v2/'
resp = requests.get(api_base + 'login_information', headers=headers)
base_url = resp.json()['loginAccounts'][0]['baseUrl']

# Identify all templates in my account
resp = requests.get(base_url + '/templates', headers=headers)
all_templates = resp.json()['envelopeTemplates']

# (Find my template, explore ways I could modify it with PUT, etc.)
template_id = find_desired_template(all_templates)
resp = requests.get(base_url + '/templates/{}'.format(template_id), headers=headers)

# Find just status changed envelopes from some recent date/datetime
resp = requests.get(base_url + '/envelopes',
                    params={'from_date': '2018-01-26'}, headers=headers)

# Configure just a single envelope to have push notifications
envelope_id = resp.json()['envelopes'][0]['envelopeId']

# Configure this _one_ envelope to notify us when completed.
# WARNING: This isn't repeatable: The next auto-created envelope won't work
event_notification = {
    "url": "https://my-own-api.example.com/some/endpoint",
    "loggingEnabled": "true",
    "requireAcknowledgment": "true",
    "useSoapInterface": "false",
    "includeCertificateWithSoap": "false",
    "signMessageWithX509Cert": "false",
    "includeDocuments": "true",
    "includeEnvelopeVoidReason": "true",
    "includeTimeZone": "true",
    "includeSenderAccountAsCustomField": "true",
    "includeDocumentFields": "true",
    "includeCertificateOfCompletion": "true",

    # Only notify on completion
    "envelopeEvents": [
        {"envelopeEventStatusCode": "completed"}
    ],
    "recipientEvents": [
        {"recipientEventStatusCode": "Completed"},
    ],
}

requests.put(base_url + '/envelopes/{}'.format(envelope_id),
             headers=headers,
             json={'eventNotification': event_notification})
#/usr/bin/env蟒蛇3
导入请求
用户名=user@example.com'
密码='某些敏感密码'
积分器键='abcdef01-2345-6789-0abcdef0123456789'
#通过DocuSign API进行身份验证,获取后续请求的基本URL
验证\u str=(
""
“”+用户名+“”
“”+密码+“”
“”+integrator_键+“”
""
)
headers={'X-DocuSign-Authentication':authenticate\u str,
'Accept':'application/json'}
美国石油学会https://demo.docusign.net/restapi/v2/'
resp=requests.get(api_base+‘login_information’,headers=headers)
base_url=resp.json()['loginAccounts'][0]['baseUrl']
#识别我的帐户中的所有模板
resp=requests.get(基本url+/templates',headers=headers)
all_templates=resp.json()['EnvelopetTemplates']
#(查找我的模板,探索使用PUT修改模板的方法,等等)
template\u id=查找所需的\u模板(所有\u模板)
resp=requests.get(base_url+/templates/{}.format(template_id),headers=headers)
#查找最近某个日期/日期时间的状态更改信封
resp=requests.get(base_url+'/envelopes',
参数={'from_date':'2018-01-26'},headers=headers)
#仅将单个信封配置为具有推送通知
信封id=resp.json()['envelopes'][0]['envelopeId']
#配置此u one uu信封,以在完成时通知我们。
#警告:这是不可重复的:下一个自动创建的信封将无法工作
事件通知={
“url”:”https://my-own-api.example.com/some/endpoint",
“loggingEnabled”:“true”,
“RequiredKnowledgment”:“true”,
“useSoapInterface”:“false”,
“includeCertificateWithSoap”:“假”,
“signMessageWithX509Cert”:“false”,
“包含文档”:“真实”,
“includeEnvelopeVoidReason”:“true”,
“includeTimeZone”:“true”,
“includeSenderAccountAsCustomField”:“true”,
“includeDocumentFields”:“true”,
“IncludeCertificateOfcCompletion”:“true”,
#仅在完成时通知
“信封事件”:[
{“envelopeEventStatusCode”:“已完成”}
],
“recipientEvents”:[
{“recipientEventStatusCode”:“已完成”},
],
}
requests.put(基本url+/信封/{}).format(信封id),
标题=标题,
json={'eventNotification':事件通知})
约束条件
我的帐户未配置为具有,这将允许我在每次完成帐户中的文档时通知HTTPS端点。我使用的是共享帐户(使用的是其他不相关的信封/模板),因此这不是一个理想的解决方案。

出于业务原因,如果购买了帐户级别的连接选项,则Connect Webhook只能与所有信封(或模板/powerform中的所有信封)关联。它作为许多帐户类型的附加组件提供

在这种情况下,正如您所提到的,您的webhook侦听器将收到它不感兴趣的信封事件通知。对于这些通知消息,请回复200(已接收),然后放弃该信息