我在通过API向信封添加自定义列表字段时遇到问题。问题实际上是以列表字段的形式出现在信封上,但当我发出“GET”请求以检索信封上的所有自定义字段时,它显示自定义字段在那里。下面是添加自定义列表字段的函数,后跟来自DocuSign的xml字符串响应。
Private Sub btnTEST_Click(sender As System.Object, e As System.EventArgs) Handles btnTEST.Click
Dim envelopeId As String = txtEnvelopeID.Text
Dim url As String = baseUrl & "/envelopes/" & envelopeId & "/custom_fields"
Dim xmlString As String =
"<customFields>" & _
"<listCustomFields>" & _
"<listCustomField>" & _
"<name>Test Custom List</name>" & _
"<value>Donatello</value>" & _
"<show>true</show>" & _
"<required>true</required>" & _
"<listItems>" & Chr(34) & "Donatello" & Chr(34) & ", " & Chr(34) & "Michaelangelo" & Chr(34) & ", " & Chr(34) & "Raphael" & ", " & Chr(34) & "Leonardo" & Chr(34) & "</listItems>" & _
"</listCustomField>" & _
"</listCustomFields>" & _
"</customFields>"
basicRequestResponse("POST", url, xmlString)
End Sub
检索信封上的自定义字段时,DocuSign的XML响应。
<customFields xmlns="http://www.docusign.com/restapi" xmlns:i="http://www.w3.or/2001/XMLSchema-instance">
<listCustomFields>
<listCustomField>
<fieldId>22047120</fieldId>
<name>Test List</name>
<required>true</required>
<show>true</show>
<value>Test 1</value>
<listItems xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a:string />
</listItems>
</listCustomField>
<listCustomField>
<fieldId>22049808</fieldId>
<name>Test Custom List</name>
<required>true</required>
<show>true</show>
<value>Donatello</value>
<listItems xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a:string />
</listItems>
</listCustomField>
</listCustomFields>
<textCustomFields>
<textCustomField>
<fieldId>21991323</fieldId>
<name>Leet Test</name>
<required>true</required>
<show>true</show>
<value>1337</value>
</textCustomField>
</textCustomFields>
我意识到这可能是DocuSign的API中的一个错误,但是想把它放在这里,看看是否有不同的答案。
答案 0 :(得分:0)
您的问题是由于您在“创建自定义信封字段”请求中错误地设置&lt; listItems&gt; 这一事实 - 因此DocuSign正在创建自定义(列表)信封字段,但忽略您在请求中指定的列表项值。
以下是添加(列表)自定义信封字段的有效XML请求结构示例:
POST https://{{env}}.docusign.net/restapi/{{version}}/accounts/{{acctId}}/envelopes/{{envelopeId}}/custom_fields
<customFields>
<listCustomFields>
<listCustomField>
<name>TestCustomList</name>
<value>Donatello</value>
<show>true</show>
<required>true</required>
<listItems>
<string>Donatello</string>
<string>Michaelangelo</string>
<string>Raphael</string>
<string>Leonardo</string>
</listItems>
</listCustomField>
</listCustomFields>
</customFields>
请注意,&lt; listItems&gt; 元素中的内容是一系列&lt; string&gt; 元素 - 每个元素代表一个列表值。
提交上述请求后,我可以执行“获取自定义信封字段”请求(GET https://{{env}}.docusign.net/restapi/{{version}}/accounts/{{acctId}}/envelopes/{{envelopeId}}/custom_fields
)并看到响应确实包含我在之前的“创建信封自定义”中指定的所有列表值字段“请求:
<customFields xmlns="http://www.docusign.com/restapi" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<listCustomFields>
<listCustomField>
<fieldId>22062595</fieldId>
<name>TestCustomList</name>
<required>true</required>
<show>true</show>
<value>Donatello</value>
<listItems
xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a:string>Donatello</a:string>
<a:string>Michaelangelo</a:string>
<a:string>Raphael</a:string>
<a:string>Leonardo</a:string>
</listItems>
</listCustomField>
</listCustomFields>
</customFields>