docuSign - envelopeViews : createRecipient - docusignapi

ERROR: Content Type specified is not supported.
Hi there, I am new to DocuSign and I am trying to learn the implementation from last couple of days. What I did so far is, created a developer account and created a QuickStart project.
Goal
I want to integrate the DocuSign API's in my application, but I don't really want the user to leave my application. I just want to make use of DocuSign within my app. - Embedded Signing
What I did?
I successfully created an envelope with a sample document and after that I have to get that URL to view (for Recipient).
So I called the below API:
** EnvelopeViews: createRecipient**
** POST - {{baseUrl}}/v2.1/accounts/{{accountId}}/envelopes/{{envelopeId}}/views/recipient**
All the details, like accountId, envelopeId are correct, along with that the request body that I pass with this is:
Request Body
{
"authenticationMethod": "none",
"clientUserId": "bcc49234-f30b-XXXX-XXXX-XXXXXXXXXXXX",
"email": "abc#gmail.com",
"recipientId": "007",
"returnUrl":"http://localhost",
"userName": "user name"
}
Note: * clientUserId is my Integration Key (please let me know if this is what I need to pass here or something else).*
Response
{
"errorCode": "INVALID_CONTENT_TYPE",
"message": "Content Type specified is not supported."
}
Note: Apart from the solution, please provide any link(s) to resources where I can easily see the implementation(as in my use case).

Umair,
First clientUserId is a bit of a confusing term, it's not the IK (Integration Key) but any string you want. It is unique to the signer and the envelope. You choose it.
You can find a detailed example of this with code in 8 languages on the DocuSign Developer Center How To Request Signature Through your app page.
I'm not clear how you make the API calls, if you are using postman, there are headers that needs to be set. One of them is called Content-Type and it has to be set to text/plain.

Related

Why is userName a required property for envelopeViews?

I'm not sure if this is a bug. But I discovered this in sandbox while creating an embedded signing link.
When attempting to call the below post with the following body, I get a 400 Bad Request Data Object errorCode: "INVALID_REQUEST_PARAMETER" message: "The request contained at least one invalid parameter. A value was not found for parameter 'userName'."
POST /v2/accounts/{accountId}/envelopes/{envelopeId}/views/recipient
Accept: application/json
Origin: https://apiexplorer.docusign.com
Content-Type: application/json
Show Base64 Bytes in Request
{
"authenticationMethod": "none",
"email": "myemail#example.com",
"returnUrl": "google.com"
}
So it makes sense to add a userName to my recipient right? Well, yes but no. I can type in any random userName like
{
"authenticationMethod": "none",
"email": "myemail#example.com",
"returnUrl": "google.com",
"userName": "sdlfkjsodisdofisdofm"
}
And it will generate the link a successful response with an embedded link. It appears to look for email first as precedence which is what I want. What's the purpose of userName here?
So, I think if the user is not authenticated ("none") then userName is ignored, but still is required. Which does seem like a bug, so good catch. If you want to do more testing - try v2.1, which is the latest API version we recommend you use and see if it behaves the same (most likley, but not 100% sure).
The reason userName may be needed is for example for InPersonSigner or when you use recipientAuthentication and the user needs to be correlated to a DocuSign user in some account to be able to use their auth correctly.
Edit: Actually, userName would be used to determine your set of signatures. Try this, set your signature and use the exact same userName. DocuSign should remember it and you won't have to do that again. If you use a different one - you would have to. So, maybe not a bug after all...
(same for the electronic consent that you only have to agree to once)

How to implement a DocuSign template natively into a Webflow site?

I have a webflow site with an order form. Once the prospect completes the order form and presses submit, the goal is to redirect the prospect to another page on the webflow site (not redirect to a DocuSign page).
On the next page, the prospect would see our customer agreement with their data from the order form already prefilled. We have a DocuSign template already with tabs already placed visually, we can map those labels to the form labels on the order form. All that should be left for prospects to do is to add their signature and submit the agreement.
If I understood the explanation above correctly, then the following steps would work our use case as well. Is this correct?
Step 1 When a prospect fills in and submits the order form on the website, the website button click will trigger a GET API request. ie. GET demo.docusign.net/restapi/login_information
Step 2 Next, a POST API request will be sent to DocuSign to create an envelope based on our template agreement. i.e. POST demo.docusign.net/restapi/:version/:accountId/envelopes In this POST request, we will also send in the request body the data labels in the template and map those to the data entered in the form submission. i.e.
"tabs": {
"textTabs": [
{
"tabLabel": "address",
"value": "Code for pulling the value from the relevant form field"
},
{
"tabLabel": "email",
"value": "Code for pulling the value from the relevant form field"
}
]
}
Step 3 Call the following GET request to display the DocuSign agreement directly on our site. --> Should this be in an iframe or another implementation? i.e. Get DocuSign Recipient View
Thank you in advance for your support!

POST request to Envelopes:create method

First of all - all code on PHP and JS.
I took all user data (sub, base_uri, account_id ) with that documentation https://developers.docusign.com/esign-rest-api/code-examples/config-and-auth at my site using cURL
Now I need send pdf file for that I generate at my site with that access for user sign like I have understood I need that https://developers.docusign.com/esign-rest-api/code-examples/signing-from-your-app and Envelopes: create https://developers.docusign.com/esign-rest-api/reference/Envelopes/Envelopes/create#examples
I send POST request to https://demo.docusign.net/restapi/v2/accounts/{accountId}/envelopes with accountId=account_id from user data, also I send json with user data and doc data in base64 in, but there is nothing, so I don't understand:
How should I call "create" method with POST to https://demo.docusign.net/restapi/v2/accounts/{accountId}/envelopes ?
What Id should I use in {accountId}?
At what format should I send the document for the sign?
Where can I find that doc after create?
Can you show me code example or show documentation with normal examples of POST request for that method.
If you are using a demo environment, I believe your authentication url is https://demo.docusign.net/restapi/v2/login_information. For production accounts, since the subdomain can be different you can find the correct baseUrl using a GET request to https://www.docusign.net/restapi/v2/login_information?api_password=true using Postman. This gives you the right baseUrl as well as your authentication information.
Here is how you can create a template using a base64 which is a POST call to {{baseUrl}}/templates
{
"documents": [
{
"documentBase64": "<insert encoded base64 here",
"documentId": "1",
"name": "blank1.pdf"
}
],
"envelopeTemplateDefinition": {}
}
Also, if you need to generate more requests make sure you check out the Postman collection that contains different examples as Sebastian mentioned too:
DocuSign Postman Collection

DocuSign API - Reset/Unlock RecipientAuthenticationStatus

I'm using the DocuSign API to electronically sign documents within my app. I'm using the access code authentication feature, for some additional security; however, I am trying to 'Unlock' a signer (via the API) that has input the wrong access code too many times, without voided and creating a new envelope, or using the DocuSign Admin interface.
I don't care if I have to resend the initial email, I just want to be able to conserve my client's total envelope count. It's also important (if there are multiple signers) that I don't force one signer to have to sign multiple times, if they completed their signatures prior to signer2's authentication error.
I have attempted a POST to:
/v2/accounts/{accountId}/envelopes/{envelopeId}?resend_envelope=true
I have also sought a solution using the docusign-java-client:
Recipients recipients = envelopesApi.listRecipients(accountId, envelopeId);
List<Signer> signers = recipients.getSigners();
for (Signer signer : signers) {
signer.setRecipientAuthenticationStatus(null);
}
I still get the below response
"recipientAuthenticationStatus": {
"accessCodeResult": {
"status": "Failed",
"eventTimestamp": "2018-01-15T23:49:15.8600000Z"
}
I'm able to "Resend" via the DocuSign admin GUI, and everything works as expected...
Is there any way that I'm able "reset/unlock" this authentication feature programatically, through the API?
You can use below PUT endpoint
PUT /restapi/v2/accounts/<accountId>/envelopes/<envelopeId>?resend_envelope=true
Body as:
{
}
This should send another email to the signer who failed the authentication, and that user will again get option to enter the access code.
I think you will need to delete and then re-add the recipient (signer). That makes the signer become a new recipient.
However, doing so means you'll need to re-create everything about the signer: their document tabs/fields, etc.
I can't imagine that it is less expensive to simply void/resend the envelope than to spend a developer's time to work on this issue.
If this scenario is occurring a lot, then perhaps think about providing better training to your signers with respect to using the access code feature.
Per the documentation found here
I must include the json or xml with the request (if the authentication method failed). I assumed incorrectly that if there was only one recipient, then I would NOT have to specify. If you just want to resend the envelope, you don't need to include and signer data.
Such as:
{"signers" :
[{"email":"testEmail#gmail.com",
"name":"FirstName LastName",
"recipientId":"1"
}]
}
You should then get something like the below response:
{"recipientUpdateResults":
[{
"recipientId": "1",
"errorDetails":
{
"errorCode": "SUCCESS",
"message": ""
}
}]
}

REST API - Recipient View - How to configure multiple returnUrl's per Event

I'm attempting to build embedded signing with my integration via REST API. I can successfully create the token with the bare minimum requirements.
{
"userName": "Derrick Test",
"email": "email#email.com",
"recipientId": "1",
"clientUserId": "1",
"returnUrl": "http://www.google.com",
"authenticationMethod": "email"
}
What I would like to enhance is redirect my signers to a specific URL on more than just completion. More specifically I would like to configure a different URL for the events:
cancel
decline
signing_complete
viewing_complete
The REST documentation does not provide a JSON example when utilizing multiple events. Has anyone else been successful with this?
With the REST API, you can only supply a single returnUrl, and it will apply for any/all events (i.e., cancel / decline / exception / fax_pending / id_check_failed / session_timeout / signing_complete / ttl_expired / viewing_complete). However, you can achieve the effect of having the user's destination be event-dependent simply by coding your return page to evaluate the event parameter in the querystring, and doing another redirect immediately to the event-specific page, depending on the value of the event querystring parameter.
For example, let's say you specify http://www.myfakesite.com/processReturn.aspx as the returnUrl value in the POST Recipient View request. When the recipient signs the document(s) and submits the Envelope, DocuSign will redirect the user to the URL: http://www.myfakesite.com/processReturn.aspx?event=signing_complete. Assuming you've built "processReturn.aspx" such that it evaluates the value of the event querystring parameter, it will see value "signing_complete" and then immediately redirect to the appropriate page (that you specify in the code) for the Signing Complete event.
Page 167 (returnUrl property description) of the REST API guide (http://www.docusign.com/sites/default/files/REST_API_Guide_v2.pdf) lists all possible values for the event parameter.

Resources