1
votes

I am changing the signer for a Specific Envelope by updating the recipient's using below code which was working fine

 EnvelopesApi envelopeApi = new EnvelopesApi();
                                var options = new EnvelopesApi.UpdateRecipientsOptions()
                                {
                                    resendEnvelope = "true",
                                    //offlineSigning="true"
                                };
                                Signer signerobj = new Signer
                                {
                                    Email = handoverOwnerEmail,
                                    Name = handoverOwnerName,
                                    RecipientId = "1",
                                    RoutingOrder = "1",

                                };
                                CarbonCopy carbonCopyobj = new CarbonCopy
                                {
                                    RecipientId = removesigner.recipientId,
                                    Name = removesigner.name,
                                    Email = removesigner.email,
                                };
                                Recipients objrecipients = new Recipients
                                {
                                    Signers = new List<Signer>() { signerobj },
                                    CarbonCopies = new List<CarbonCopy> { carbonCopyobj }
                                };
                                RecipientsUpdateSummary result1 = envelopeApi.UpdateRecipients(accoutnId, folderitem.envelopeId, objrecipients, options);

The above code return the same status for both valid email or wrong email. If i provide invalid email the status of the envelope in the sent items becomes Failure as show in the below imageenter image description here. If we login to Docusign we had a option to correct the recipient details.

Is it possible to get the failure status envelopes and update the recipient email using the rest API.

I am thinking of that we can get the failure envelopes and will update the recipient's with valid recipient emails

2

2 Answers

0
votes

We have an automated job that checks for bounced emails. Here is the code using XML:

  strURL = DocuSign_Get_AcctInfo
  If strURL = "" Then
    GoTo Exit_StdExit
  End If

  strURLGetSent = strURL & "/envelopes?from_date=" & strFromDate & "&status=sent"

  Set XDoc = CreateObject("MSXML2.DOMDocument.6.0")
  XDoc.SetProperty "SelectionLanguage", "XPath"
  XDoc.SetProperty "SelectionNamespaces", "xmlns:r='http://www.docusign.com/restapi' xmlns:i='http://www.w3.org/2001/XMLSchema-instance'"
  XDoc.async = False
  XDoc.validateOnParse = True

  With DocEnv
    .Open "GET", strURLGetSent, False
    .setRequestHeader "Content-Type", "application/xml"
    .setRequestHeader "Accept", "application/xml"
    .setRequestHeader "X-DocuSign-Authentication", "<DocuSignCredentials><Username>" + strUsrNm + "</Username><Password>" + strPssWrd + "</Password><IntegratorKey>" + strKey + "</IntegratorKey></DocuSignCredentials>"
    .Send
    XDoc.LoadXML (PrettyPrintXml(.responseText))
  End With
'  XDoc.Save ("U:\data\DocuSign\notsigned.xml")

  If XDoc.parseError <> 0 Then
    MsgBox "Invalid XML!" & vbCrLf & vbCrLf & XDoc.parseError.reason
    GoTo Exit_StdExit
  End If

  lngRcrdCnt = XDoc.SelectSingleNode("//r:resultSetSize").Text
  If lngRcrdCnt = 0 Then
    Email_Bounced = True  'query worked but returned no records
    GoTo Exit_StdExit
  End If
  ReDim AcctID(lngRcrdCnt - 1)
  lngIdx = 0
  'loop through the collection of nodes to capture the envelopeID
  Set XNodes = XDoc.SelectNodes("//r:*")
  For Each XNode In XNodes
    If XNode.nodeName = "envelopeID" Then
      AcctID(lngIdx) = XNode.Text
      lngIdx = lngIdx + 1
    End If
  Next XNode

  For lngIdx = 0 To lngRcrdCnt - 1
    strURLGetBounce = strURL & "/envelopes/" & AcctID(lngIdx) & "/recipients"
    Set responseDoc = CreateObject("MSXML2.DOMDocument.6.0")
    responseDoc.SetProperty "SelectionLanguage", "XPath"
    responseDoc.SetProperty "SelectionNamespaces", "xmlns:r='http://www.docusign.com/restapi' xmlns:i='http://www.w3.org/2001/XMLSchema-instance'"
    responseDoc.async = False
    responseDoc.validateOnParse = True
    With DocRecip
      .Open "GET", strURLGetBounce, False
      .setRequestHeader "Content-Type", "application/xml"
      .setRequestHeader "Accept", "application/xml"
      .setRequestHeader "X-DocuSign-Authentication", "<DocuSignCredentials><Username>" + strUsrNm + "</Username><Password>" + strPssWrd + "</Password><IntegratorKey>" + strKey + "</IntegratorKey></DocuSignCredentials>"
      .Send
      responseDoc.LoadXML (PrettyPrintXml(.responseText))
    End With

    Set XNodes = responseDoc.SelectNodes("//r:errorCode")
    For Each XNode In XNodes
      MsgBox "The following error has occurred: " & XNode.Text & vbCrLf & vbCrLf & "See file U:\data\DocuSign_PutResponseError.xml" & " for more info"
      GoTo Exit_StdExit
    Next XNode

    If responseDoc.SelectSingleNode("//r:status").Text = "autoresponded" Then
    'this call sets the values for lngPrsnID, lngFctyApptAID
      Call DocuSign_Get_CustomFlds(strURL & "/envelopes/" & AcctID(lngIdx) & "/custom_Fields", lngPrsnID, lngFctyApptAID)
      strEmail = responseDoc.SelectSingleNode("//r:email").Text
      modConnection.OpenADODBConnection.Execute ("insert into _FctyLtrsEmlBounce(lngPrsnID, lngFctyApptAID, strEmlDocuSign) values(" & lngPrsnID & ", " & lngFctyApptAID & ", '" & strEmail & "')")
    End If
  Next lngIdx
''''
0
votes

Connect can send you a webhook notification if a recipient's email address results in an autoresponded email. I think that is the error that results in the Failure notification.

I doubt that a bad email address instantly results in the Failure status. Instead, DocuSign attempts to send to the provided email address and if the send fails with an email error back to DocuSign, then you see the Failure status.

You may also be able to see the errors by using Envelopes::get, Envelopes::listStatus, or Envelopes::listStatusChanges

Update: check the recipient statuses to see if any of the recipients has the autoresponded status.

Since email addressing errors are detected asynchronously, Connect (or eventNotification for a specific envelope) is the best way to go. Otherwise you'll need to poll for status changes.