使用PUT方法REST更新收件人电子邮件

时间:2013-07-24 15:21:55

标签: api rest docusignapi

我是REST的新手,并通过以下代码继续获取错误请求400响应:

我有来自其他样本的标准baseURL和authenticateStr ......

_recipientID,pNewEmail,pNewName和pNewRoutingOrder作为参数传递给过程。

            string envDef = "<envelopeDefinition xmlns=\"http://www.docusign.com/restapi\">" +
                                "<signers>" +
                                    "<signer>" +
                                            "<recipientId>" + _recipientId + "</recipientId>" +
                                            "<email>" + pNewEmail + "</email>" +
                                            "<name>" + pNewName + "</name>" +
                                            "<routingOrder>" + pNewRoutingOrder + "</routingOrder>" +
                                    "</signer>" +
                                "</signers>" +
                            "</envelopeDefinition>"; 

        url = baseURL + "/envelopes/" + pEnvelopeID + "/recipients";
        request = (HttpWebRequest)WebRequest.Create(url);
        request.Headers.Add("X-DocuSign-Authentication", authenticateStr);
        request.ContentType = "application/xml";
        request.Accept = "application/xml";
        request.ContentLength = envDef.Length;
        request.Method = "PUT";
        // write the body of the request
        byte[] body = System.Text.Encoding.UTF8.GetBytes(envDef);
        Stream dataStream = request.GetRequestStream();
        dataStream.Write(body, 0, envDef.Length);
        dataStream.Close();
        // read the response
        webResponse = (HttpWebResponse)request.GetResponse();
        sr.Close();

        responseText = "";
        sr = new StreamReader(webResponse.GetResponseStream());
        responseText = sr.ReadToEnd(); 

1 个答案:

答案 0 :(得分:0)

好的,只是弄清楚如何做到这一点。例如,这是一个XML请求主体,可用于更新收件人的电子邮件和名称。我刚刚确认这是有效的!

<recipients xmlns="http://www.docusign.com/restapi">
   <signers>
      <signer>
         <recipientId>1</recipientId>
         <email>email@docusign.com</email>
         <name>Joe Mama</name>
      </signer>
   </signers>
</recipients>