预先设置Docusign模板字段

时间:2013-10-07 23:04:43

标签: php codeigniter rest docusignapi

所以我在我们的DocuSign模板中尝试从我们的自定义界面提交它们时预先填充一些字段,但请求似乎无法在模板中找到它们。我们正在使用REST,cURL和Codeigniter。我的数据数组如下:

$data = array("accountId" => $accountId,
    "emailSubject" => "Hello World!",
    "emailBlurb" => "This comes from PHP",
    "templateId" => "********-****-****-****-************",
    "templateRoles" => array(
                           array(
                               "email" => "****@******.com",
                               "name" => "**** *****",
                               "roleName" => "LC3"
                           ),
                           array(
                               "email" => $this->input->post("applicant_email"),
                               "name" => $this->input->post("applicant_name"),
                               "roleName" => "Applicant",
                               "tabStatuses" => array(
                                                    "textTabs" => array (
                                                                      array (
                                                                          "tabLabel" => "lic_num",
                                                                          "tabValue" => $this->input->post("license_number")
                                                                      ),
                                                                      array (
                                                                          "tabLabel" => "ubi_num",
                                                                          "tabValue" => $this->input->post("ubi_number")
                                                                      ),
                                                                      array (
                                                                          "tabLabel" => "tra_nam",
                                                                          "tabValue" => $this->input->post("trade_name")
                                                                      )
                                                                   )
                                                 )
                            )
                      ),
    "status" => "sent"); 

我尝试使用制表符而不是tabStatuses,但这也不起作用,我们的XML响应有TabStatuses而不是Tabs。自API演练提出以来有什么变化吗?

编辑:经过Chrome的Postman扩展程序的大量试验和错误后,这是我实际上没有出错的JSON请求:

{
    "accountId":"c771ba8c-2947-4bec-acab-15b1b48a11b6",
    "emailSubject":"Hello World!",
    "emailBlurb":"This comes from PHP",
    "templateId":"B96D0480-8792-43E8-AE11-E2AEAC74E601",
    "templateRoles":[
        {
            "email":"mike@cloudpwr.com",
            "name":"Mike Longmire",
            "roleName":"LC3",
            "tabStatuses":[
                {
                    "tabStatus":[
                        {
                            "tabLabel":"lic_num",
                            "tabValue":"1111"
                        },
                        {
                            "tabLabel":"ubi_num",
                            "tabValue":"2222"
                        },
                        {
                            "tabLabel":"tra_nam",
                            "tabValue":"Flakey"
                        }
                     ]
                 }
             ],
             "email":"duckie715@gmail.com",
             "name":"Mike Longmire",
             "roleName":"Applicant"
        }
     ],
    "status":"sent"
}

我得到了同样的答复:

{
    "envelopeId": "0063d398-36b7-4e2f-8515-6ed9ab62aaeb",
    "uri": "/envelopes/0063d398-36b7-4e2f-8515-6ed9ab62aaeb",
    "statusDateTime": "2013-10-08T18:05:54.9926661Z",
    "status": "sent"
}

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

这很可能是由于JSON中的函数调用返回的值没有被引号(“)标记包裹而引起的。为了测试这个理论,我首先只是硬编码一些值,无论你在哪里在你的JSON中有一个函数调用(例如"email" => $this->input->post("applicant_email"))并用实际的电子邮件等替换并运行。

如果您仍然收到400错误,那么您的请求还有其他问题。如果不这样做,那么您只需要在这些函数调用传回的值前面添加引号并附加引号。

例如,您可以分配变量,例如

$applicantEmail_1 = $this->input->post("applicant_email")

然后设置您的JSON,如:

"templateRoles" => array(
                       array(
                           "email" => "****@******.com",
                           "name" => "**** *****",
                           "roleName" => "LC3"
                       ),
                       array(
                           "email" => "$applicantEmail_1",
                           "name" => $this->input->post("applicant_name"),
                           "roleName" => "Applicant",
                       ...

关于PHP的好处是即使该变量是双引号,变量的值仍将插入引号内。