调用docusign的create_edit_view接口报INVALID_REQUEST_BODY错误如何解决?
问题原因
DocuSign的Python SDK对TemplateViews : createEdit接口的封装要求显式传入请求体对象,你当前的调用逻辑没有传递该参数,导致请求无有效body触发报错。官方REST接口文档里虽然仅将accountId、templateId标注为必填路径参数,但该接口实际属于POST请求,需要携带包含跳转地址的请求体结构,API Explorer测试时会自动补全默认的请求体结构,所以可以正常返回结果。
修复步骤
- 先导入请求体模型:
from docusign_esign.models import TemplateViewRequest
- 构造请求体并调用接口,
return_url为用户完成模板编辑后DocuSign跳转的业务地址,可根据自己的需求配置:
api_client = ApiClient( header_name="Authorization", header_value=f"Bearer {access_token}", host="https://demo.docusign.net/restapi/" ) # 构造请求体 template_view_req = TemplateViewRequest(return_url="https://你的业务跳转地址") # 调用接口时传入请求体参数 response = TemplatesApi(api_client).create_edit_view( account_id=account_id, template_id=template_id, template_view_request=template_view_req )
调用后从response的url字段即可获取模板编辑页面的访问地址。
内容的提问来源于stack exchange,提问作者R_M_R
相关产品推荐
相关产品推荐

