【发布时间】:2020-01-21 17:42:04
【问题描述】:
我在尝试通过其 API 服务发送带有自定义收件人邮件(使用 recipientMailNotification)的 Docusign envelope 时遇到问题。我的控制器正确接收请求,但在它发送到 docusign 服务之前,它会反序列化为一个对象,这就是错误发生的时候。
**JSON Request:**
"Recipients": [{
"Order": 1,
"Name": "Andre Test ",
"Email": "andre@test.com",
"SignerType": "SIGNER",
"DocusignSignerType": 0,
"SignatureType": "ELECTRONIC",
"EtapaFinalizada": false,
"EmailNotification":{
"emailBody": "SIGN AS SIGNER",
"emailSubject": "SIGNER SIGNATURE REQUIRED"
}
},
{
"Order": 2,
"Name": "Luis Teste",
"Email": "luis@test.com",
"SignerType": "WITNESS",
"DocusignSignerType": 0,
"SignatureType": "ELECTRONIC",
"EtapaFinalizada": false,
"EmailNotification": {
"emailBody": "SIGN AS WITNESS",
"emailSubject": "WITNESS SIGNATURE REQUIRED"
}
}
]
给我错误:
'Cannot deserialize the current JSON object
(e.g. {"name":"value"}) into type 'System.Collections.Generic.List`1[eSignature.
Providers.Docusign.Entities.RecipientEmailNotification]'
我没有使用任何类型的列表 或数组。只是嵌套在另一个内部的标准属性。
尝试了here 列出的解决方案,但仍然出现错误。
使用 Json2CSharp 给了我与我当前类相同的结构,所以我认为它是正确的 Json。
编辑:请注意,我什至没有在我的类属性上使用数组或列表:
public class Destinatario
{
public int Order { get; set; }
public string Name { get; set; }
public string Email { get; set; }
public string SignerType{ get; set; }
public int DocusignSignerType{ get; set; }
public string SignatureType{ get; set; }
public bool EtapaFinalizada { get; set; }
public RecipientEmailNotification EmailNotification { get; set; }
}
【问题讨论】:
-
您使用的是 DocuSign.eSign.dll nuget 包吗?如果是这样 - 什么版本?
-
@InbarGazit 没有。我只使用 eSign Rest API 2.1 版
-
好的,所以您使用的是自己的对象,所以我真的不知道序列化失败的原因是什么。我建议你考虑使用 nuget,不会有这个问题。
-
我已经看到一个问题 - 您需要将所有内容更改为字符串。没有 int/bool 等。都是字符串。
-
您确实在反序列化 json 时需要一个列表,因为您有一个
Recipients数组。向我们展示您的反序列化调用,错误就在那里。否则,它应该可以工作,请参阅这个小提琴example。
标签: json api json.net docusignapi serialization