如何通过API重发DocuSign信封?仅重发待签署人遇404错误
DocuSign信封重发404错误解决(仅重发待签署人)
问题场景
需要通过Envelope ID重发DocuSign信封,且仅发送给待签署人而非所有签署人,使用以下VB代码后返回404资源不存在错误:
Using client As New HttpClient() client.BaseAddress = New Uri("https://demo.docusign.net/restapi/v2.1/") client.DefaultRequestHeaders.Accept.Clear() client.DefaultRequestHeaders.Accept.Add(New MediaTypeWithQualityHeaderValue("application/json")) client.DefaultRequestHeaders.Authorization = New AuthenticationHeaderValue("Bearer", "eyJ0eXAiOiJNVCIsImFs.....") ' Resend the envelope Dim response = client.PutAsync($"envelopes/a5b268be-d0be-4103-a079-09d814c/resend", Nothing).Result If response.IsSuccessStatusCode Then Return "001:Mail resent successfully" Else Return "002:" & "Failed to resend Mail. Error: " & response.StatusCode End If End Using
收到的错误响应:
"StatusCode: 404, ReasonPhrase: 'The URL provided does not resolve to a resource.', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
X-Content-Type-Options: nosniff
X-DocuSign-TraceToken: a5890c7a-f183-4050-99d5-b72376a0b806
X-DocuSign-Node: DA3DFE181
Strict-Transport-Security: max-age=31536000; includeSubDomains
Cache-Control: no-cache
Date: Thu, 13 Jul 2023 09:39:40 GMT
Content-Length: 0
}}"
错误原因
- API路径缺失账户ID:DocuSign v2.1的所有核心接口都需要指定账户ID,原路径
envelopes/{envelopeId}/resend不符合规范,正确路径应为accounts/{accountId}/envelopes/{envelopeId}/resend。 - 未发送必要请求体:仅重发待签署人需要在请求体中指定
resend_type=remaining,且不能发送空请求,需携带JSON格式的参数。
修正方案
- 补充账户ID到API路径(可通过DocuSign控制台或用户信息接口获取)
- 构造包含重发规则的JSON请求体,设置
resend_envelope=true和resend_type=remaining - 为请求设置
Content-Type: application/json头
修正后的完整VB代码
Using client As New HttpClient() client.BaseAddress = New Uri("https://demo.docusign.net/restapi/v2.1/") client.DefaultRequestHeaders.Accept.Clear() client.DefaultRequestHeaders.Accept.Add(New MediaTypeWithQualityHeaderValue("application/json")) client.DefaultRequestHeaders.Authorization = New AuthenticationHeaderValue("Bearer", "eyJ0eXAiOiJNVCIsImFs.....") ' 替换为实际的账户ID和信封ID Dim accountId As String = "YOUR_ACCOUNT_ID" Dim envelopeId As String = "a5b268be-d0be-4103-a079-09d814c" ' 构造重发请求体,指定仅重发给待签署人 Dim requestBody As String = "{""resend_envelope"": true, ""resend_type"": ""remaining""}" Dim content As New StringContent(requestBody, Encoding.UTF8, "application/json") ' 发送带请求体的Put请求 Dim response = client.PutAsync($"accounts/{accountId}/envelopes/{envelopeId}/resend", content).Result If response.IsSuccessStatusCode Then Return "001:Mail resent successfully" Else Dim errorContent = response.Content.ReadAsStringAsync().Result Return $"002:Failed to resend Mail. Error: {response.StatusCode} - {errorContent}" End If End Using
关键说明
resend_type参数支持两种值:all(重发给所有签署人)、remaining(仅重发给待签署人),这里使用remaining满足需求。- 必须确保Bearer令牌拥有
envelope:update权限。 - 若仍有错误,可读取响应的错误内容(示例中已添加
ReadAsStringAsync),获取更详细的错误信息。
内容的提问来源于stack exchange,提问作者aravindb
相关产品推荐
相关产品推荐

