当我将carbonCopies
添加到recipients
数组时,我一直收到此错误:
{“errorCode”:“INVALID_REQUEST_BODY”,“message”:“请求正文是 丢失或格式不正确。无法反序列化当前的JSON 对象(例如{\“name \”:\“value \”})进入类型 'API_REST.Models.v2.carbonCopy []'因为类型需要JSON 数组(例如[1,2,3])以正确反序列化。\ r \ n要修复此错误 要么将JSON更改为JSON数组(例如[1,2,3]),要么更改 反序列化类型,以便它是一个普通的.NET类型(例如,不是 原始类型,如整数,而不是像数组或类似的集合类型 List)可以从JSON对象反序列化。 JsonObjectAttribute 也可以添加到类型中以强制它从JSON反序列化 对象。\ r \ n路径'recipients.carbonCopies.name',第1行,第274位。“ }
以下是我的要求。
Array
(
[emailBlurb] => Please click "view documents" to electronically sign your document.
[emailSubject] => - Something Agreement
[documents] => Array
(
[0] => Array
(
[documentId] => 1
[name] => Merchant Services Agreement.pdf
)
)
[recipients] => Array
(
[carbonCopies] => Array
(
[name] => Customer Name
[email] => email@domain.com
[routingOrder] => 1
[recipientId] => 1
)
[signers] => Array
(
[0] => Array
答案 0 :(得分:0)
你在carbonCopies部分之后缺少额外的数组声明。既然你在这里使用PHP就是JSON的样子,以及print_r()调用中该对象的样子。
更正JSON:
"recipients": {
"signers": [
{
"email": "test@docusign.com",
"name": "John Doe",
"recipientId": "1",
"tabs": {
"signHereTabs": [
{
"xPosition": "100",
"yPosition": "100",
"documentId": "1",
"pageNumber": "1"
}
]
}
}
],
"carbonCopies": [
{
"email": "test@gmail.com",
"name": "Sally Doe",
"recipientId": "2"
}
]
}
这是print_r()调用中对象的样子:
[recipients] => Array
(
[signers] => Array
(
[0] => Array
(
[email] => test@docusign.com
[name] => John Doe
[recipientId] => 1
[tabs] => Array
(
[signHereTabs] => Array
(
[0] => Array
(
[xPosition] => 100
[yPosition] => 100
[documentId] => 1
[pageNumber] => 1
)
)
)
)
)
[carbonCopies] => Array
(
[0] => Array
(
[email] => test@gmail.com
[name] => Sally Doe
[recipientId] => 2
)
)
)
[status] => sent
)