1
votes

I'm trying to use the Docusign API to create an envelope to get the sender view for an uploaded document, and then afterwards, get the recipient view.

The sender part worked fine. I created the request with all the information and I was able to send the document and open it in the console and add my signature tabs.

myResponse = getResponseBody(myRequest)
Dim uri As String = parseDataFromResponse(myResponse, "uri")
Dim envelopeId As String = 
    parseDataFromResponse(myResponse, "envelopeId")

url = baseURL + uri + "/views/sender"
Dim returnUrl As String = "http://whatever.com"
xmlBody = 
    "<returnUrlRequest xmlns=""http://www.docusign.com/restapi"">
    <returnUrl>" & returnUrl & "</returnUrl></returnUrlRequest>"
myRequest = initializeRequest(url, "POST", xmlBody, username, password,
    integratorKey)
myResponse = getResponseBody(myRequest)
Session("senderViewUrl") = parseDataFromResponse(myResponse, "url")

It worked fine. I redirected the browser to the senderViewURL and it created the envelope. The next few lines of code I want to be able to get the returnUrl from the recipient view so I can embed it into an iframe on my site for another user but I'm getting a 400 BAD REQUEST. Everything looks fine to me. I tried it with and without the "authenticationInstant" tag.

url = baseURL + uri + "/views/recipient"
Dim requestBody As String = "<recipientViewRequest         
    xmlns=""http://www.docusign.com/restapi"">" &
    "<authenticationMethod>email</authenticationMethod>" &
    "<email>" & recipientEmail & "</email>" &
    "<returnUrl>http://whatever2.com</returnUrl>" &
    "<clientUserId>" & clientId & "</clientUserId>" &
    "<userName>" & recipientName & "</userName>" &
    "</recipientViewRequest>"
myRequest = initializeRequest(url, "POST", requestBody, username,
    password, integratorKey)
myResponse = getResponseBody(myRequest)
Session("recipientViewUrl") = parseDataFromResponse(myResponse, "url")

Both url's use use the same envelope ID. Do I need a completely separate envelope for the recipient view request?

If so, is there ANY WAY to get the URL of the recipient view after I create the sender view request. I need a returnURL for the sender view so when the user finishes it.. my application marks the document in my own DB as having gone out. I need to be able to have a returnURL for the recipientview as well so once it's signed I can have my application record that it's been signed.

Added

And yes the clientUserId is defined when the envelope is first created. The Embedded Sending page is missing something.

It says for Step 3 do this: "Get DocuSign Sender View" and then receives recipient view URL.... but NOWHERE in the code examples does it actually show how/where to get that recipient view URL. It only shows you have to get the SENDER VIEW URL so you can tag and send, but this is misleading.... you're not actually getting the recipient view URL.

Also, in the last request to get the recipient view I change the recipientViewRequest to returnUrlRequest... still nothing... 400 bad request.

Here is the original xml body when the envelope was created:

"<envelopeDefinition xmlns=""docusign.com/restapi"">"; & 
    "<emailSubject>Test</emailSubject>" & 
    "<status>created</status>" &
    "<documents>" & 
        "<document>" & 
            "<documentId>1</documentId>" & 
            "<name>" & documentName & "</name>" & 
        "</document>" & 
    "</documents>" & 
    "<recipients>" & 
        "<signers>" & 
            "<signer>" & 
                "<recipientId>1</recipientId>" & 
                "<clientUserId>" & clientId & "</clientUserId>" & 
                "<email>" & recipientEmail & "</email>" & 
                "<name>" & recipientName & "</name>" & 
                "<tabs>" & 
                    "<signHereTabs>" & 
                        "<signHere>" & 
                            "<documentId>1</documentId>" & 
                            "<pageNumber>1</pageNumber>" & 
                        "</signHere>" & 
                    "</signHereTabs>" & 
                    "<dateSignedTabs>" & 
                        "<dateSigned>" & 
                            "<documentId>1</documentId>" & 
                            "<pageNumber>1</pageNumber>" & 
                            "<fontSize>Size12</fontSize>" & 
                            "<underline>true</underline>" & 
                            "<bold>true</bold>" & 
                        "</dateSigned>" & 
                    "</dateSignedTabs>" & 
                "</tabs>" & 
            "</signer>" & 
        "</signers>" & 
    "</recipients>" & 
"</envelopeDefinition>" 

I changed the to "sent" and it still didn't work. 400 Bad Request – Brian Lorraine 23 hours ago

Another weird thing. Notice how under "documents" and "signers" I have "document" and "signer" child elements. Everyone out there I see with examples leaves out the child elements and puts their signer and document information directly under "documents" and "signers" and it seems to work fine for them.

Once I remove "document" and "signer" child elemnts and just have (for e.g.) "", skipping the "document" element completely, docusign throws a 400 Bad request. What give? Why is everyone else able to skip these child nodes except for me?

2
FYI that big gap that is between the recipientViewRequest tag and the xmlns element in the second example isn't actually in my code... just bad formatting on the site hereBrian Lorraine
And yes the clientUserId is defined when the envelope is first created. This page: (iodocs.docusign.com/APIWalkthrough/embeddedSending) is missing something. It says for Step 3 it does this: "Get DocuSign Sender View" and then receives recipient view URL.... but NOWHERE in the code examples does it actually show how/where to get that recipient view URL. It only shows you have to get the SENDER VIEW URL so you can tag and send, but this is misleading.... you're not actually getting the recipient view URL.Brian Lorraine
Also, in the last request to get the recipient view I change the recipientViewRequest to returnUrlRequest... still nothing... 400 bad requestBrian Lorraine
Here is a look at the actual original xmlbody that created the envelopeBrian Lorraine
Here is the original xml body when the envelope was created:Brian Lorraine

2 Answers

1
votes

I'm trying to use the DocuSign API to create an envelope to get the sender view for an uploaded document, and then afterwards, get the recipient view.

Congratulations on using the API to initiate an envelope and to provide your sender with the Sender View. The Sender View enables document tagging. Once the Sender is finished, she can send the document out for signing.

Embedded Signing is completely different from Embedded Sending. Embedded Signing is a part of a different workflow. You may or may not need it.

Embedded Signing (also known as the "Recipient View") is used when you have a web application which authenticates people. After the signer has authenticated herself, the web app can provide an Embedded Signing view to enable the signer to sign documents.

The documents to be signed can already exist (they're waiting to be signed). Or the documents can be created on-the-fly by the app and then immediately signed within the app.

To use Embedded Signing, see the Embedded Signing walk-through. It is a different walk-through than Embedded Sending since the two actions are completely different.

Please note that the Embedded Signing url returned to your application needs to be used soon after it is generated. It is time-bound. So you must only generate the Embedded Signing URL when the signer is ready to sign.

Also note that the Recipient View method was updated since the Embedded Signer walk through was written. An update to the walk through is planned. But in the meantime, note that the following attributes should or must be set to properly retrieve the Recipient View URL:

authenticationMethod This is how your web app authenticated the signer. Eg "Partner web site user" or "Project X web site user".

assertionId This could be the signer's user name or user ID on your web site.

authenticationInstant When was the signer authenticated by your website?

Details on the above parameters.

The above three attributes are used to record the authentication method you used to assure that the signer is who she says she is. Some of the info is added to the Certificate of Completion for the envelope and all of it is stored.

If the signer later tries to repudiate her signature, the information is used to disprove the repudiation.

0
votes

Thanks for the help. Your resources were useful.

However I found the answer to my question. It was pretty simple. Note how I create the envelope with one request, then get the sender view url, then get the recipient view url all in one linear shot?

My problem is that I was simply just opening the recipient view console before the sender view console. Duh! If you try to do this, there isn't anything that has been sent yet, hence why it fails.

Basically, when debugging, I was stopping on the senderviewurl and opening that in another browser, adding the tags and sending... then continuing with the debugging.

Once I stopped debugging and ran it linearly, it tries to get the recipientviewurl BEFORE the sendviewviewurl has even been opened, so if the document hasn't been sent yet, there is no recipientview.

There's no way anyone could have known this, but I'm putting my answer in here in case any beginners run into this in the future and starts banging their head against the wall.