Envelope is not configured for support of recipient signing providers - docusignapi

I am trying to send an envelope to be signed via digital certificate, I am receiving the following message.
com.docusign.esign.client.ApiException: Error while requesting server, received a non successful HTTP code 400 with response Body:
{
"errorCode":"SIGNATURE_PROVIDER_INVALID_FOR_NONSBS",
"message":"Signature providers are not valid for this recipient. Standards Based Signatures must be enabled for the sending account. Envelope is not configured for support of recipient signing providers"
}
Here is code:
private EnvelopeDefinition makeEnvelope(WorkArguments args, Object resumo) throws IOException {
Tabs signerTabs = EnvelopeHelpers.createSignerTabs(EnvelopeHelpers.createSignHere("**signature_1**", ANCHOR_OFFSET_Y, ANCHOR_OFFSET_X));
Signer signer = new Signer();
signer.setEmail(resumo.getMail();
signer.setName(resumo.getName());
signer.setRecipientId("1");
signer.setRoutingOrder("1");
signer.setTabs(signerTabs);
RecipientSignatureProvider provider = new RecipientSignatureProvider();
// provider.setSignatureProviderName("UniversalSignaturePen_ICP_SmartCard_TSP");
provider.setSignatureProviderName("UniversalSignaturePen_ImageOnly");
List<RecipientSignatureProvider> lstProvider = new ArrayList<RecipientSignatureProvider>();
lstProvider.add(provider);
signer.setRecipientSignatureProviders(lstProvider);
EnvelopeDefinition envelope = new EnvelopeDefinition();
envelope.setEmailSubject("Email Test");
envelope.setDocuments(Arrays.asList(EnvelopeHelpers.createDocumentFromFile(resumo.getDirRel(), resumo.getDisplayName(),"1")));
envelope.setRecipients(EnvelopeHelpers.createRecipients(signer));
envelope.setStatus(EnvelopeHelpers.ENVELOPE_STATUS_SENT);
return envelope;
}

The error is caused by a missing/not enabled plan feature. You will need to contact sales team and check with them if SBS - Standard Based Signature is included in your plan

Related

event notification of envelope in DocuSign restapi c#,webapi

I have added event notification at the time of envelope creation in EnvelopeCreate Method as
apiClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + AccessToken);
EnvelopesApi envelopesApi = new EnvelopesApi(apiClient);
EnvelopeSummary results = envelopesApi.CreateEnvelope(AccountId, env);
EventNotificationForEnvelope();
and EventNotificationForEnvelope method is as
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
EnvelopeDefinition envelopeDefinition = new EnvelopeDefinition();
var eventNotification = new EventNotification();
// Set up the endpoint URL to call (it must be using HTTPS and at least TLS1.1 or higher)
eventNotification.Url = "https:\\testapi.example.com/api/DocuSignEventNotification";
// DocuSign will retry on failure if this is set
eventNotification.RequireAcknowledgment = "true";
// This would send the documents together with the event to the endpoint
eventNotification.IncludeDocuments = "true";
// Allows you to see this in the DocuSign Admin Connect logs section
eventNotification.LoggingEnabled = "true";
var envelopeEvents = new List<EnvelopeEvent>();
// In this case we only add a single envelope event, when the envelope is completed. You can also add events for recipients
envelopeEvents.Add(new EnvelopeEvent { EnvelopeEventStatusCode = "completed",
IncludeDocuments = "true" });
eventNotification.EnvelopeEvents = envelopeEvents;
envelopeDefinition.EventNotification = eventNotification;
and in my api's controller as
public class DocuSignEventNotificationController : ApiController
{
[HttpPost]
[HttpGet]
public HttpResponseMessage DocuSignDocumentStatus(HttpResponseMessage responseMessage)
{
dynamic response = responseMessage.Content.ReadAsStringAsync();
//here I will read values from response and use in my application
return Request.CreateResponse(HttpStatusCode.OK, "Testing");
}
}
I am not getting any response on envelope create and when status is updating of that envelope
A couple of things.
First,
https:\testapi.example.com/api/DocuSignEventNotification
Is not where you have your server I presume. Make sure that you use https and that your server is configured correctly to accepts TLS (1.2 and above).
Using a cloud service or some other third-party instead of building your own is much easier. If you do use your own, you may need to ensure firewall etc. allow for requests coming from the internet.
Second,
There's a log that you can find in the Connect section settings area in the DocuSign web app that can show you all attempts to reach servers. That can help you figure out if the request was made correctly to DocuSign and if DocuSign attempted to call your server and if so - what error may have been returned.
Just click "Logs":

DocuSign - View Form Data

Another company we partner with sends us new client information via DocuSign envelopes completed by those clients. I am attempting to extract the form data from the document, either via the PDF or via the DocuSign API. The PDF only appears to have the Envelope ID embedded in it. When I add my account as a CC recipient and try to view the form data in the DocuSign console, I receive an error message:
Additionally, I'm unable to view the form data via the DocuSign API.
{
errorCode: "USER_LACKS_PERMISSIONS",
message: "This user lacks sufficient permissions to access this resource."
}
I've tried accessing via the API at:
/v2/accounts/{accountId}/envelopes/{envelopeId}/recipients/{recipientId}/tabs
/v2/accounts/{accountId}/envelopes/{envelopeId}/documents/{documentId}/fields
Questions:
Is there a way for a user who is not in the sender's tenant to be able to view the envelope form data?
Is there a way for DocuSign to embed the tab data into the PDF for extraction?
Is there another approach I'm not considering?
If the user is cc to the envelope using the same userId and email combination that is on their account, then that user also can use the API to gain account information. (account is what you call "tenant.")
If the user is not on the envelope and you just receive the PDF some other way, then you cannot use the API to obtain information about the envelope because that is limited only to recipients of the envelope.
#Inbar-Gazit was kind enough to do some digging internally at DocuSign, and after a bit of back-and-forth, discovered that this is possible using the SOAP API with the RequestEnvelope and RequestEnvelopeV2 methods. I'm unsure if there's any advantage to using one method over the other. Both also have async methods.
https://developers.docusign.com/docs/esign-soap-api/reference/Status-and-Managing-Group/RequestEnvelope
Some quick-and-dirty C# validated that this will indeed work. I validated this both as the sending account (which also works via REST) and the CC recipient account (which did not work via REST).
var authString = $"<DocuSignCredentials><Username>{_userName}</Username><Password>{_password}</Password><IntegratorKey>{_apiKey}</IntegratorKey></DocuSignCredentials>";
var client = new DSAPIServiceSoapClient();
using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
{
HttpRequestMessageProperty httpRequestProperty = new HttpRequestMessageProperty();
httpRequestProperty.Headers.Add("X-DocuSign-Authentication", authString);
OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = httpRequestProperty;
EnvelopeStatus status = client.RequestStatusEx(_envelopeId);
Console.Out.WriteLine("Subject: " + status.Subject);
// RequestEnvelope Method
var envelope = client.RequestEnvelope(_envelopeId, false);
var testTab = envelope.Tabs.FirstOrDefault(t => t.TabLabel.Contains("Test"));
if (testTab != null)
{
Console.WriteLine($"Tab {testTab.TabLabel}: {testTab.Value}");
} else
{
Console.WriteLine("Tab not found.");
}
// RequestEnvelopeV2 Method
var requestOptions = new RequestEnvelopeV2Options() {
IncludeAC = false,
IncludeAnchorTabLocations = true,
IncludeDocumentBytes = false
};
var envelopeV2 = client.RequestEnvelopeV2(_envelopeId, requestOptions);
var testTabV2 = envelopeV2.Tabs.FirstOrDefault(t => t.TabLabel.Contains("Test"));
if (testTabV2 != null)
{
Console.WriteLine($"Tab(v2) {testTabV2.TabLabel}: {testTabV2.Value}");
} else
{
Console.WriteLine("Tab(v2) not found.");
}
Console.WriteLine("\r\nDone.");
Console.ReadKey();
}
Output:
Subject: Please DocuSign: Test Envelope
Tab txtDataLabelTest1: Some Data Here
Tab(v2) txtDataLabelTest1: Some Data Here
Done.

DocuSign using TemplateID remote signing and Webhook notification for AutoResponded (non-existing signer email)

I'm not getting any webhook notifications for bad email addresses that respond back with unknown mail recipients. I do get a notification email for this but no webhook notification.
envelope code setup
{
var envelopeDefinition = new EnvelopeDefinition()
{
EmailSubject = request.EmailSubject,
EventNotification = new EventNotification()
{
RequireAcknowledgment = "true",
Url = config.Value.EnvelopeEventUrl,
EnvelopeEvents = new List<EnvelopeEvent>
{
//new EnvelopeEvent("Delivered"),
new EnvelopeEvent(EnvelopeEventStatusCode: "Voided"),
new EnvelopeEvent(EnvelopeEventStatusCode: "Declined"),
new EnvelopeEvent(EnvelopeEventStatusCode: "Completed", true.ToString()),
},
RecipientEvents = new List<RecipientEvent>
{
new RecipientEvent(RecipientEventStatusCode:"AuthenticationFailed"),
new RecipientEvent(RecipientEventStatusCode:"AutoResponded"),
new RecipientEvent(RecipientEventStatusCode:"Delivered"),
new RecipientEvent(RecipientEventStatusCode:"Declined"),
new RecipientEvent(RecipientEventStatusCode:"Completed"),
}
},
TemplateId = request.TemplateId,
Status = "Sent",
EmailSettings = new EmailSettings(ReplyEmailAddressOverride: "Reply#xxxxFinance.com.au", ReplyEmailNameOverride: "John Smith"),
};
Sadly this DocuSign link is broken
See Using Webhooks to Track Envelope Status for details
Also I can't login to support using my DocuSign Demo account (Sandbox account), not sure why, so can't log a support ticket!
So, first of - the link is not broken. Not sure what you meant by that.
Second, the issue here may be that sometimes remote servers do not respond back very quickly to let you know an email bounced.
You could try a different strategy where you look for the positive message (that the status of the recipient changed to indicate the email message was sent succsefully) and if you don't get that within say, 5 min - you assume it bounced (but that's on you, sometimes it is just delayed a lot).
See, you subscribed to five different recipient events. The one called "Delivered" is the positive (or opposite) of "AutoResponded" (which may also mean that the person had their Out-Of-Office message on). So, by checking if it was delivered, you can tell when the message got there safely, but not when it bounced for sure.

Email notification to user is not sent when ClientUserId is provided

I'm trying to create envelope from template i uploaded to my account.
Using following code to do that:
public static void main(String[] args) throws ApiException {
// Enter your DocuSign credentials
String UserName = "my-user-name";
String Password = "my-password";
String IntegratorKey = "my-integrator-key";
// for production environment update to "www.docusign.net/restapi"
String BaseUrl = "https://demo.docusign.net/restapi";
// initialize the api client for the desired environment
ApiClient apiClient = new ApiClient();
apiClient.setBasePath(BaseUrl);
// create JSON formatted auth header
String creds = "{\"Username\":\"" + UserName + "\",\"Password\":\"" + Password + "\",\"IntegratorKey\":\"" + IntegratorKey + "\"}";
apiClient.addDefaultHeader("X-DocuSign-Authentication", creds);
// assign api client to the Configuration object
Configuration.setDefaultApiClient(apiClient);
//////////////////////////////// LOGIN START
// login call available off the AuthenticationApi
AuthenticationApi authApi = new AuthenticationApi();
// login has some optional parameters we can set
AuthenticationApi.LoginOptions loginOps = authApi.new LoginOptions();
loginOps.setApiPassword("true");
loginOps.setIncludeAccountIdGuid("true");
LoginInformation loginInfo = authApi.login(loginOps);
// note that a given user may be a member of multiple accounts
List<LoginAccount> loginAccounts = loginInfo.getLoginAccounts();
System.out.println("LoginInformation: " + loginAccounts);
// use the |accountId| we retrieved through the Login API to create the Envelope
String accountId = loginAccounts.get(0).getAccountId();
/////////////////////////////////////// LOGIN END
////////////////////////////////////// CREATE ENVELOPE START
// create a new envelope object that we will manage the signature request through
EnvelopeDefinition envDef = new EnvelopeDefinition();
envDef.setEmailSubject("Hey! Sign the following document");
// assign template information including ID and role(s)
envDef.setTemplateId("ebbe20e3-1c2e-4696-a0c4-41269bf54aeb");
// create a template role with a valid templateId and roleName and assign signer info
TemplateRole tRole = new TemplateRole();
tRole.setRoleName("Client");
String name = "Jake";
String email = "someEmail#goes.here";
tRole.setName(name);
tRole.setEmail(email);
tRole.setClientUserId("someClientUuid");
// create a list of template roles and add our newly created role
List<TemplateRole> templateRolesList = new ArrayList<>();
templateRolesList.add(tRole);
Tabs tabs = new Tabs();
Text clientIdField = new Text();
clientIdField.setTabLabel("CustomerId");
clientIdField.setValue("I changed text from API! It works!");
List<Text> textList = new ArrayList<>();
textList.add(clientIdField);
tabs.setTextTabs(textList);
tRole.setTabs(tabs);
// assign template role(s) to the envelope
envDef.setTemplateRoles(templateRolesList);
// send the envelope by setting |status| to "sent". To save as a draft set to "created"
envDef.setStatus("sent");
// use the |accountId| we retrieved through the Login API to create the Envelope
// instantiate a new EnvelopesApi object
EnvelopesApi envelopesApi = new EnvelopesApi();
// call the createEnvelope() API
EnvelopeSummary envelopeSummary = envelopesApi.createEnvelope(accountId, envDef);
System.out.println("EnvelopeSummary: " + envelopeSummary);
///////////////////////////////////// CREATE ENVELOPE END
String envelopeId = envelopeSummary.getEnvelopeId();
//////////////////////////////////////// CREATE RECIPIENT VIEW
// use the |accountId| we retrieved through the Login API
// instantiate a new EnvelopesApi object
// set the url where you want the recipient to go once they are done signing
RecipientViewRequest returnUrl = new RecipientViewRequest();
returnUrl.setReturnUrl("https://www.docusign.com/devcenter");
returnUrl.setAuthenticationMethod("email");
// recipient information must match embedded recipient info we provided in step #2
returnUrl.setEmail(email);
returnUrl.setUserName(name);
returnUrl.setClientUserId("someClientUuid");
// call the CreateRecipientView API then navigate to the URL to start the signing session
ViewUrl recipientView = envelopesApi.createRecipientView(accountId, envelopeId, returnUrl);
System.out.println("ViewUrl: " + recipientView);
//////////////////////////////////////// CREATE RECIPIENT VIEW
}
And i noticed strange thing - when i provide clientUserId field to my TemplateRole, while creating envelope from template - email notification to sign document is not sent to user. But when i remove this field - email is sent successfully.
The problem is that i need that clientUserId in my TemplateRole to be able to properly generate ViewUrl to use in my application.
So is it a bug or a feature, that notification is not sent with provided clientUserId in TemplateRole? Did not found any documentation about that on official site.
When clientUserId is specified the recipient is considered as an embedded recipient. By default only remote recipients receive email notifications.
If you want embedded recipients to receive email notifications then set the embeddedRecipientStartURL property.
tRole.setEmbeddedRecipientStartURL("SIGN_AT_DOCUSIGN")
See this answer for more information
Official Documentation

Use the Outlook/Office365 REST API to send mail from connected email address

I am trying to send an email using the Outlook/Office 365 REST API, and I am trying to send it as an address that I have as a "Connected Account". Attempting to send the message returns a `` error. However, the API will let me create a draft with this address.
Additionally, I can send the API-created draft just fine, and I can also create and send messages as this account from the web interface.
Is there a way to authorize the API to be able to send a message as an address for a connected account?
No, the API doesn't support this today. It has to do with the scope of the permissions that you consent to. "Allow this app to send mail as you" covers sending from your account, but not from another account, even if you have been granted access.
Another thing you can think about is to leverage App-only authentication. You can configure a Azure AD App to have App-only authentication. After that, all the request will behalf of that app id and you should be able to delegate that app id to send email to anyone on behalf of the user you want.
The following is the steps:
Create a Azure AD application.
Configure your Azure AD Application to allow App-only token by
following Build service and daemon apps in Office 365. You also
need a certificate for app-only token request.
Go to your Azure AD Application->Configuration, Click "Add
application" to add "Office 365 Exchange Online". Select "Send email
as any user" under "Application permission" dropdown box. It allows
your Azure AD App to have permission to send email on behalf of
someone.
Once you have Azure AD application configured, you can refer the
following code for sending email on behalf of a specific user.
string tenantId = "yourtenant.onmicrosoft.com";
string clientId = "your client id";
string resourceId = "https://outlook.office.com/";
string resourceUrl = "https://outlook.office.com/api/v2.0/users/service#contoso.com/sendmail"; //this is your on behalf user's UPN
string authority = String.Format("https://login.windows.net/{1}", AUTHORITYURL, tenantId);
string certificatPath = #"c:\test.pfx"; //this is your certficate location.
string certificatePassword = "xxxx"; // this is your certificate password
var itemPayload = new
{
Message = new
{
Subject = "Test email",
Body = new { ContentType = "Text", Content = "this is test email." },
ToRecipients = new[] { new { EmailAddress = new { Address = "test#cotoso.com" } } }
}
};
//if you need to load from certficate store, use different constructors.
X509Certificate2 certificate = new X509Certificate2(certficatePath, certificatePassword, X509KeyStorageFlags.MachineKeySet);
AuthenticationContext authenticationContext = new AuthenticationContext(authority, false);
ClientAssertionCertificate cac = new ClientAssertionCertificate(clientId, certificate);
//get the access token to Outlook using the ClientAssertionCertificate
var authenticationResult = await authenticationContext.AcquireTokenAsync(resourceId, cac);
string token = authenticationResult.AccessToken;
//initialize HttpClient for REST call
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer " + token);
client.DefaultRequestHeaders.Add("Accept", "application/json");
//setup the client post
HttpContent content = new StringContent(JsonConvert.SerializeObject(itemPayload));
//Specify the content type.
content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json;odata=verbose");
HttpResponseMessage result = await client.PostAsync(url, content);
if(result.IsSuccessStatusCode)
{
//email send successfully.
}else
{
//email send failed. check the result for detail information from REST api.
}
For a complete explanation, please reference to my blog Send email on behalf of a service account using Office Graph API
I hope it helps and let me know if you have questions.

Resources