1

I am trying to send a draft envelope using the rest xml api I have saved but I get a Bad Request error. This is the code I have:

string url = baseURL + "/accounts/" + loginAccount.accountId + "/envelopes/" + envelopeID;

        string requestBody = "<status xmlns=\"http://www.docusign.com/restapi\">sent</status>";

        HttpWebRequest requestSendEnvelop = initializeRequest(url, "PUT", requestBody, Username, Password, Key);
        string response = getResponseBody(requestSendEnvelop);

What would be the right request?

Thanks.

EpicDev
  • 27
  • 5

2 Answers2

1

The XML body for a request that sends a Draft envelope should look like this:

<envelope xmlns="http://www.docusign.com/restapi">
   <status>sent</status>
</envelope>

For future reference, the DocuSign REST API Help page contains documentation of request/response format for all API calls (in both JSON and XML): https://www.docusign.net/restapi/help.

Kim Brandl
  • 13,125
  • 2
  • 16
  • 21
  • @EpicDev, are you able to provide a trace of your request, along with the DocuSign Authentication headers? – WTP API Jul 29 '14 at 18:44
  • Ok for the headers I have {X-DocuSign-Authentication: josefse@gmail.comLagz54HAHA-675d55aa-6692-42f8-b5bd-afdda69af248 Accept: application/xml Content-Type: application/xml Host: demo.docusign.net } – EpicDev Jul 29 '14 at 19:03
  • As "WTP API" requested, you're more likely to get assistance if you update your question with a full trace of the HTTP request. You can easily produce such a trace with a tool like "Fiddler" -- start Fiddler, submit the API request, then copy the full request (verb, URI, headers, XML body) from Fiddler and paste it into your original question above. Doing so will provide the necessary info for troubleshooting. – Kim Brandl Jul 29 '14 at 20:02
  • hi and thanks for your reply, What I am trying to do is to have a embedded senders view so that customers and add documents and recipients and then have my own send button so that customers click mine and not the one that comes with the embedded view whenever they are sending out an envelope, so I already have the embedded view and my send button, but how would I create do a request so that the envelope is sent once customers are done adding recipients and documents? Please use xml format if possible. – EpicDev Jul 29 '14 at 21:10
1

It looks like you are hitting the wrong endpoint. When you get your baseUrl returned from the Login API call it will be in this format:

"baseUrl": "https://demo.docusign.net/restapi/v2/accounts/123456"

In the little code you posted I see the following:

string url = baseURL + "/accounts/" + loginAccount.accountId + "/envelopes/" + envelopeID;

This would in turn produce:

"baseUrl": "https://demo.docusign.net/restapi/v2/accounts/123456/accounts/12345/envelopes/..."

Try fixing your endpoint and using the request body that Kim posted, i.e.

<envelope xmlns="http://www.docusign.com/restapi">
   <status>sent</status>
</envelope>

And make sure that you are doing a PUT and not a POST for the method.

Ergin
  • 9,254
  • 1
  • 19
  • 28