You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Dropbox Sign Create Template API报400错误,求非SDK方式解决

问题

我尝试使用Dropbox Sign Create Template API创建新模板,以下是我的C#代码片段:

string content = "{\"client_id\":\"XXXXXXXXXXXXXXXXXXXXXXXXX\",\"file_urls\":[\"https://www.dropbox.com/s/ad9qnhbrjjn64tu/mutual-NDA-example.pdf?dl=1\"],\"title\":\"DocuSign_Template_001\",\"subject\":\"Complete with Docusign\",\"message\":\"Complete\",\"signer_roles\":[{\"name\":\"Meghan\",\"order\":0}],\"cc_roles\":null,\"merge_fields\":null,\"field_options\":null,\"form_fields_per_document\":[{\"document_index\":0,\"api_id\":\"11c7e79e-168b-4548-ad64-0c64e4a16ace\",\"name\":\"\",\"type\":\"signature\",\"x\":714,\"y\":57,\"width\":120,\"height\":30,\"required\":true,\"signer\":0,\"page\":1}],\"test_mode\":true}";

var requestContent = new StringContent(content, Encoding.UTF8, "application/json");
var response = await client.PostAsync("https://api.hellosign.com/v3/template/create", requestContent);

if (response.IsSuccessStatusCode)
{
    string responseBody = await response.Content.ReadAsStringAsync(); 
}
else
{
    string responseBody = await response.Content.ReadAsStringAsync();
    //{"error":{"error_msg":"form fields are required","error_path":"form_fields_per_document","error_name":"bad_request"}}
}                            

创建模板请求返回状态码400,错误信息为:{"error":{"error_msg":"form fields are required","error_path":"form_fields_per_document","error_name":"bad_request"}}

我已按照官方文档设置表单字段,但不想使用仅支持.NET 6.0及以上版本的Dropbox Sign .NET SDK,恳请指导如何修复该错误。


解决方案

问题根源

你的请求JSON存在两个核心格式错误:

  1. form_fields_per_document结构不符合API要求,表单字段未嵌套在form_fields数组中
  2. signer_roles缺少必填的role_name字段,导致签名者与表单字段无法关联

修正步骤

1. 调整form_fields_per_document结构

API要求每个form_fields_per_document元素必须包含form_fields数组,所有表单字段需放入该数组内,而非直接作为元素的属性。

2. 完善signer_roles字段

signer_roles中的每个对象必须包含role_name(模板角色的唯一标识),同时表单字段需通过signer_role_name关联该角色名,而非使用signer索引。

3. 移除不必要的api_id

创建模板时api_id由API自动生成,手动指定可能触发校验问题,建议删除该字段。

修正后的代码

JSON请求体(格式化后)

{
  "client_id": "XXXXXXXXXXXXXXXXXXXXXXXXX",
  "file_urls": ["https://www.dropbox.com/s/ad9qnhbrjjn64tu/mutual-NDA-example.pdf?dl=1"],
  "title": "DocuSign_Template_001",
  "subject": "Complete with Docusign",
  "message": "Complete",
  "signer_roles": [{"role_name": "Meghan", "name": "Meghan", "order": 0}],
  "cc_roles": null,
  "merge_fields": null,
  "field_options": null,
  "form_fields_per_document": [
    {
      "document_index": 0,
      "form_fields": [
        {
          "name": "",
          "type": "signature",
          "x": 714,
          "y": 57,
          "width": 120,
          "height": 30,
          "required": true,
          "signer_role_name": "Meghan",
          "page": 1
        }
      ]
    }
  ],
  "test_mode": true
}

转义后的C#字符串

string content = "{\"client_id\":\"XXXXXXXXXXXXXXXXXXXXXXXXX\",\"file_urls\":[\"https://www.dropbox.com/s/ad9qnhbrjjn64tu/mutual-NDA-example.pdf?dl=1\"],\"title\":\"DocuSign_Template_001\",\"subject\":\"Complete with Docusign\",\"message\":\"Complete\",\"signer_roles\":[{\"role_name\":\"Meghan\",\"name\":\"Meghan\",\"order\":0}],\"cc_roles\":null,\"merge_fields\":null,\"field_options\":null,\"form_fields_per_document\":[{\"document_index\":0,\"form_fields\":[{\"name\":\"\",\"type\":\"signature\",\"x\":714,\"y\":57,\"width\":120,\"height\":30,\"required\":true,\"signer_role_name\":\"Meghan\",\"page\":1}]}],\"test_mode\":true}";

内容的提问来源于stack exchange,提问作者Gags

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.22 15:17:03