我是 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();