How to create Signature Request with DocuSign for HTML format? - json

I have it working for PDF and now want to try an HTML document. I am using the method of POSTing a JSON object containing the document bytes base64 encoded. The only examples I find online are using the multipart/form-data method but I would much prefer to just POST a JSON object w/ the document base64 encoded like I did for PDF. Perhaps I need to encode the HTML differently from how I encoded the PDF?
"errorCode": "ANCHOR_TAG_PROCESSING_FAILURE",
"message": "An Error Occurred during anchor tag processing. Invalid document"
Here's the JSON I am POSTing:
{
"recipients": {
"signers": [
{
"email": "my.email#gmail.com",
"name": "Dummy test",
"recipientId": 1,
"tabs": {
"dateSignedTabs": [{
"anchorString": "signer1date",
"fontSize": "Size12",
"name": "Date Signed",
"recipientId": "1",
"tabLabel": "date_signed"
}],
"fullNameTabs": [{
"anchorString": "signer1name",
"fontSize": "Size12",
"name": "Full Name",
"recipientId": "1",
"tabLabel": "Full Name"
}],
"signHereTabs": [
{
"anchorString": "signer1sig",
"name": "Please sign here",
"optional": "false",
"recipientId": "1",
"scaleValue": 1,
"tabLabel": "signer1sig"
}
]
}
}
]
},
"emailSubject": "Dummy Test Request a signature via email",
"documents": [
{
"documentId": "1",
"name": "index.html",
"documentBase64": "PCFET0NUWVBFIGh0bWw+CjxodG1sPgo8aGVhZCBsYW5nPSJlbiI+Cjx0aXRsZT5Eb2N1c2lnbiBUZW1wbGF0ZTwvdGl0bGU+CjwvaGVhZD4KPGJvZHk+CgoJPGgxPlRyYWRlIEFzc2lnbm1lbnQgQWdyZWVtZW50PC9oMT4KCTxoNCBpZD0iRGF0ZWRBc09mIj5mZWFmPC9oND4KCTxoNCBpZD0iQmV0d2VlbiI+ZmVhZjwvaDQ+Cgk8aDQgaWQ9ImFuZCI+ZmVhZjwvaDQ+CgkKCTxwPnNpZ25lcjFkYXRlPC9wPgoJPHA+c2lnbmVyMW5hbWU8L3A+CgoKPC9ib2R5Pgo8L2h0bWw+"
}
],
"status": "sent"
}

According to the documentation there is a node for fileExtension, when not default (PDF), I believe this needs to be explicitly set.
https://docs.docusign.com/esign/restapi/Envelopes/Envelopes/create/

Related

PayPal JSON format updating order

I know I am close on this, the error messages are getting nicer. Currently, I can call a similar call to update the seller's email no issue via Postman currently, working on updating the amount and associated objects. Something in my request format is off.
Is my breakdown section in the correct location? The amount_breakdown documentation looks like it is on same level as value and currency_code, so does it need to move into that section.
Here's my request JSON via Postman:
[
{
"op": "replace",
"path": "/purchase_units/#reference_id=='default'/amount",
"value": {
"currency_code": "CAD",
"value": "2",
"amount": {
"currency_code": "CAD",
"value": "2",
"breakdown": {
"item_total": {
"currency_code": "CAD",
"value": "2"
},
"tax_total": {
"value": "0",
"currency_code": "CAD"
}
}
},
"items": [
{
"name": "First Product Name",
"description": "Optional descriptive text..",
"unit_amount": {
"currency_code": "CAD",
"value": "2"
},
"tax": {
"value": "0",
"currency_code": "CAD"
},
"quantity": "1"
}
]
}
}
]
RESPONSE:
{
"name": "UNPROCESSABLE_ENTITY",
"details": [
{
"field": "/purchase_units/#reference_id=='default'/amount/breakdown/item_total",
"location": "body",
"issue": "ITEM_TOTAL_REQUIRED",
"description": "If item details are specified (items.unit_amount and items.quantity) corresponding amount.breakdown.item_total is required."
}
],
"message": "The requested action could not be performed, semantically incorrect, or failed business validation.",
"debug_id": "acecd3643c994",
"links": [
{
"href": "https://developer.paypal.com/docs/api/orders/v2/#error-ITEM_TOTAL_REQUIRED",
"rel": "information_link",
"method": "GET"
}
]
}
Thanks for any help!
Different variations of objects.
I can get the other PATCH operation working no issue but it is much simpler in object structure
There should be no amount key under the /amount path, and the items array does not belong at that /amount path either.

Jmeter: JSON response manipulation and passing to the next http request

I've got the response from HTTP GET request as JSON file and I want to use that JSON and pass it to the next HTTP request. I got the following response data
{
"apiInfo": {
"id": "23143",
"name": "bookkeeping",
"state": "used",
"data": "15893712000000"
},
"apiDetails": [
{
"bookName": "abc",
"state": "old",
"noOfTimesUsed": "53"
"additionalParam"{
"name": "abc",
"id": "123"
}
},
{
"bookName": "def",
"state": "new",
"noOfTimesUsed": "5",
"action": "keep"
"additionalParam"{
"name": "def",
"id": "456"
}
},
{
"bookName": "xyz",
"state": "avg",
"noOfTimesUsed": "23"
"additionalParam"{
"name": "ghi",
"id": "789"
}
},
{
"bookName": "pqr",
"state": "old",
"noOfTimesUsed": "75",
"action": "discard"
"additionalParam"{
"name": "jkl",
"id": "012"
}
}
]
}
I want to use "apiInfo" & "apiDetails" part from the JSON response and manipulate its data. As you can notice, some array field have attribute "action" in it and some one doesn't. I want to make sure all the field in the array have this data and is assigned as ' "action":"keep" '. Also, I want to add "id" from apiInfo & "name" from additionalParams from apiDetails itself. The end result I want is somewhat like this
"apiDetails": [
{
"id": "23143",
"bookName": "abc",
"state": "old",
"noOfTimesUsed": "53",
"action": "keep",
"name":"abc"
},
{
"id": "23143",
"bookName": "def",
"state": "new",
"noOfTimesUsed": "5",
"action": "keep",
"name":"def"
},
{
"id": "23143",
"bookName": "xyz",
"state": "avg",
"noOfTimesUsed": "23",
"action": "keep",
"name":"ghi"
},
{
"id": "23143",
"bookName": "pqr",
"state": "old",
"noOfTimesUsed": "75",
"action": "keep",
"name":"jkl"
}
]
I've been trying to use JSR223 sampler and have been struggling with it. It's bit complicated and I need help. P.S.: I've tried using javascript code to manipulate the results as desired but have been unsuccessful.
Please help.
Thanks, Sid
Add JSR223 PostProcessor as a child of the request which returns the above JSON
Put the following code into "Script" area:
def apiDetails = new groovy.json.JsonSlurper().parse(prev.getResponseData()).apiDetails
apiDetails.each { apiDetail ->
apiDetail.put('action', 'keep')
}
vars.put('request', new groovy.json.JsonBuilder(apidetails: apiDetails.collect()).toPrettyString())
That's it, you should be able to refer the generated request as ${request} where required
More information:
Apache Groovy - Parsing and producing JSON
Apache Groovy - Why and How You Should Use It

Getting an API generated in-person signing envelope tracked through Salesforce Connect

I'm using the rest API to create an in person signing session from salesforce. My envelope creation json is like this:
{
"documents": [{
"documentBase64": "'+base64EncodedDocToSign+'",
"documentId": "1",
"fileExtension": "pdf",
"name": "contract.pdf"
}
],
"emailSubject": "Please Sign",
"recipients": {
"inPersonSigners": [{
"email": "some#gsome.com",
"name": "Luis",
"hostEmail": "some#gsome.com",
"hostName": "Luis",
"signerEmail": "other#gother.com",
"signerName": "Charles",
"recipientId": "1",
"tabs": {
"signHereTabs": [{
"anchorString": "s1",
"anchorXOffset": "0",
"anchorYOffset": "0",
"anchorIgnoreIfNotPresent": "false",
"anchorUnits": "inches"
}
]
},
"routingOrder": "1",
"clientUserId": "1000",
"embeddedRecipientStartURL": "SIGN_AT_DOCUSIGN",
}
]
},
"status": "sent"
}
The next step would be for the object to be tracked using Connect. Connect is properly configured for the object and works if I "Sign with Docusign" or use a custom button.
I understand I must change the json to include the DSFSSourceObjectId custom field, with value equal to the Id of the object that is originating the request, but if I try to get a customField in there the json is not properly formatted anymore.
I tried adding the customField like:
...
}
]
},
"customFields": [
{
"Name": "DSFSSourceObjectId",
"Value": "' + objectId + '"
}
],
"status": "sent"
}
Is this viable?
I got this working adding the following to the JSON:
"customFields": {
"textCustomFields": [{
"value": "salesforceId",
"required": "false",
"show": "false",
"name": "DSFSSourceObjectId"
}
]
},

Optional DocuSign editor before sending

I am using the DocuSign API to generate digital agreements. So far all has gone well, but I now have a requirement to optionally have the contract sent to a user for editing within DocuSign before it is sent to the signatories.
My existing API calls are fairly simple, just using a template for the document:
POST https://demo.docusign.net/restapi/v2/accounts/<account_id>/envelopes HTTP/1.1
{
"status": "sent",
"templateId": "<template_id>",
"templateRoles": [
{
"email": "person1#company.com",
"name": "Person One",
"roleName": "Signatory1"
},
{
"email": "person2#somewhere.com",
"name": "Person Two",
"roleName": "Signatory2"
}
]
}
I need to have the same template sent to an editing user to adjust the envelope details before delivering to the signatories.
Anybody had any luck with a similar requirement?
Things I have tried:
Adding a compositeTemplates to the above request with an inline template that has an editor. This unfortunately removes all of the fields from the document.
Placing the whole request in compositeTemplates with the template selected as a server template, and the recipients in an inline template. This does not correctly match up the recipient roles to the template roles.
You can use the following composite template to add an Editor in addition to the template roles you have.
{
"status": "sent",
"compositeTemplates": [
{
"serverTemplates": [
{
"sequence": "2",
"templateId": "<template_id>"
}
],
"inlineTemplates": [
{
"sequence": "1",
"recipients": {
"signers": [
{
"email": "person1#company.com",
"name": "Person One",
"roleName": "Signatory1",
"recipientId": "1"
},
{
"email": "person2#company.com",
"name": "Person Two",
"roleName": "Signatory2",
"recipientId": "2"
}
],
"editors": [
{
"name": "person three",
"email": "personthree#company.com",
"recipientId": "3",
"routingOrder": "0"
}
]
}
}
]
}
]
}

Create DocuSign Envelope with Custom Fields

I am trying to add custom fields at the envelope level via the REST API and cannot get the values to be retained. The custom fields have been defined in the UI and come over in the envelope, but without the value that was assigned. If I add a custom field that was not defined in the UI, then it does not come over at all.
If I add the new custom field in a second call after the envelope is initially created, it will work, but that seems extraneous. What am I doing wrong?
Here is the JSON for creating a new custom field in the envelope:
{
"emailSubject": "Please Print, Complete and Sign Document",
"emailBlurb": "Please print and complete documents and sign on paper. ",
"status": "sent",
"customFields": {"textCustomFields":[{"name":"MyOwnField","required":"true","show":"true","value":"MyValue"}]},
"compositeTemplates": [{
"inlineTemplates": [{
"sequence": "1",
"recipients": {
"signers": [{
"requireSignOnPaper": "true",
"name":"Millard Fillmore",
"email":"dgilbert#firstallied.com",
"recipientId": "1",
"routingOrder": "1"
}]
}
}],
"document":
{
"documentId": "1",
"name": "Corestone Account Application.pdf",
"transformPdfFields": false
}
}]
}
The customFields object needs to be located inside the inlineTemplate object. Try this instead:
{
"emailSubject": "Please Print, Complete and Sign Document",
"emailBlurb": "Please print and complete documents and sign on paper. ",
"status": "sent",
"compositeTemplates": [{
"inlineTemplates": [{
"sequence": "1",
"customFields": {
"textCustomFields": [{
"name": "MyOwnField",
"required": "true",
"show": "true",
"value": "MyValue"
}]
},
"recipients": {
"signers": [{
"requireSignOnPaper": "true",
"name": "Millard Fillmore",
"email": "dgilbert#firstallied.com",
"recipientId": "1",
"routingOrder": "1"
}]
}
}],
"document": {
"documentId": "1",
"name": "Corestone Account Application.pdf",
"transformPdfFields": false
}
}]
}