Adobe Echo Sign Sending PDF file - echosign

I am working on Adobe Echo sign,I have downloaded the sample code from their website, I am using this sample code for sendingdocument, it has some code missing in sendDocument method so I have changed it. It's giving SoapHeader Exception,with nothing in InnerException,
{"apiActionId=XHZI4WF4BV693YS"}
below is my code of sending document
public static void sendDocument(string apiKey, string fileName, string recipient)
{
ES = new EchoSignDocumentService16();
FileStream file = File.OpenRead(fileName);
secure.echosign.com.FileInfo[] fileInfos = new secure.echosign.com.FileInfo[1];
fileInfos[0] = new secure.echosign.com.FileInfo(fileName, null, file);
SenderInfo senderInfo = null;
string[] recipients = new string[1];
recipients[0] = recipient;
DocumentCreationInfo documentInfo = new DocumentCreationInfo(
recipients,
"Test from SOAP: " + fileName,
"This is neat.",
fileInfos,
SignatureType.ESIGN,
SignatureFlow.SENDER_SIGNATURE_NOT_REQUIRED
);
DocumentKey[] documentKeys;
senderInfo = new SenderInfo(recipient, "password", "APIKEY");
documentKeys = ES.sendDocument(apiKey, senderInfo, documentInfo);
Console.WriteLine("Document key is: " + documentKeys[0].documentKey);
}
its giving exception on this line
documentKeys = ES.sendDocument(apiKey, senderInfo, documentInfo);
Can anyone suggest some sample code of Adobe Echo Sign?

On the account page of your login there is an API log you can check. If you check the log entry for your request you may find more information there.
I can't see anything immediately wrong with your code however the EchoSign API guide says that the 'tos' field is deprecated and that the recipients field should be used instead. Helpfully this means you can't use the paramaterised constructor. Try creating your document creation info as such (this is C# but if you need Java it should be straightforward to figure out):
RecipientInfo[] recipientInfo = new RecipientInfo[1];
recipientInfo[0] = new RecipientInfo
{
email = "recipient",
role = RecipientRole.SIGNER,
roleSpecified = true
};
DocumentCreationInfo documentCreationInfo = new DocumentCreationInfo
{
recipients = recipientInfo,
name = "Test from SOAP: " + fileName,
message = "This is neat.",
fileInfos = fileInfos,
signatureType = SignatureType.ESIGN,
signatureFlow = SignatureFlow.SENDER_SIGNATURE_NOT_REQUIRED
};
Note that when using the recipientInfo array it seems that the roleSpecified field must be set to true. This little field tripped me up for ages and I was receiving errors similar to yours.

Related

How to send email to different recipient with a different set of data in SSIS or by SQL?

Please suggest me how to achieved this:
The other table having set of data which I need to send:
Now by using SSIS we have to send the set of data to that email. In production I'm having 135 emails and have send them a separate data which contain their set of area.
#pp#gmial.cpm will get only data where subject is maths.
I have no idea to create variable of how to pass variable.
Can any one help me with this?
I use this method a lot for sending emails:
public static void SendEmail(List<string> to, string subject, string body, string filepathName = null)
{
using (MailMessage mail = new MailMessage())
{
string from = ConfigurationManager.AppSettings["EmailFrom"];
SmtpClient SmtpServer = new SmtpClient("your email server");
mail.From = new MailAddress(from);
foreach(string t in to)
mail.To.Add(new MailAddress(t));
mail.Subject = subject;
mail.ReplyToList.Add("your reply to email");
mail.IsBodyHtml = true;
mail.Body = body;
mail.Bcc.Add("enter your email if you want to be copied");
if (filepathName != null)
{
Attachment file;
file = new Attachment(filepathName);
mail.Attachments.Add(file);
}
SmtpServer.Port = 2525; //this is unique to you
SmtpServer.Credentials = new NetworkCredential(from, ConfigurationManager.AppSettings["EmailPassword"]);
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);
}
}
This won't completely solve your problem but will give you option of sending HTML emails straight from SSIS Script task.
You won't be able to use configuration manager, you will need to "hard code" that.

GOOGLE DOCS API Invalid requests[0].updateTextStyle: Index 4 must be less than the end index of the referenced segment, 2.",

I've created a document using Google Docs API, but when I try to modify its options or add text, it gives me this error:
http://prntscr.com/naf0nm
The thing is if I open the document and click enter many times ( to make many lines) then execution and modification works. Can anyone help me?? What do I need to do to not get this error?
String text1 = "hola, llegó papa";
List<Request> requests = new ArrayList<>();
requests.add(new Request().setInsertText(new InsertTextRequest()
.setText(text1)
.setLocation(new Location().setIndex(25))));
BatchUpdateDocumentRequest body = new BatchUpdateDocumentRequest().setRequests(requests);
BatchUpdateDocumentResponse response = service.documents()
.batchUpdate(idDoc, body).execute();
Here the method to create doc:
private static void createDoc(Docs service) throws IOException {
Document doc = new Document()
.setTitle("TEXTO CAMBIADO");
doc = service.documents().create(doc)
.execute();
System.out.println("Created document with title: " + doc.getTitle());
idDoc = doc.getDocumentId();
}
It is very late for answer but it can help to others.
May be this answer can help you. someone has answered here
Also you have to write backword to get the last inserted text at the starting of doc.
I just found another way to write text at end of doc. You don't need to set the location, just do this way..
public void insertText(Docs docsService) throws IOException {
List<Request> requests = new ArrayList<>();
requests.add(new Request().setInsertText(new InsertTextRequest()
.setText("Name : {{NAME}}\n")
.setEndOfSegmentLocation(new EndOfSegmentLocation())));
requests.add(new Request().setInsertText(new InsertTextRequest()
.setText("\nDOB: {{DOB}}\n")
.setEndOfSegmentLocation(new EndOfSegmentLocation())));
requests.add(new Request().setInsertText(new InsertTextRequest()
.setText("\nMobile: {{MOBILE}}\n")
.setEndOfSegmentLocation(new EndOfSegmentLocation())));
BatchUpdateDocumentRequest body = new BatchUpdateDocumentRequest().setRequests(requests);
BatchUpdateDocumentResponse response = docsService.documents()
.batchUpdate(Constants.DOCUMENT_ID, body).execute();
}

Swagger UI doesn't support uploading a file properly for RestEasy

I use a JAX-RS (RestEasy) along with a Swagger. One of my endpoint can upload a file. Defined way to upload the file (in RestEasy) is to provide a org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput as a parameter.
Here is my endpoint:
#PUT
#Path("/apis/{id}/file")
#Consumes(MediaType.MULTIPART_FORM_DATA)
#Produces(MediaType.APPLICATION_JSON)
#ApiOperation(value = "Registers a file.", code = 201, nickname = "registerFile")
#ApiResponses(
value = {
#ApiResponse(code = 201, message = "File created.",
response = FileCreated.class),
#ApiResponse(code = 400, message = "Invalid parameters."),
#ApiResponse(code = 404, message = "API is not found.")})
Response registerFile(
#ApiParam(value = "API ID.", required = true) #PathParam("id") String apiId,
#ApiParam(value = "File to register.", required = true, type = "file", name = "apiFile")
MultipartFormDataInput apiFile) throws AppException;
What is the problem?
Unfortunately, swagger-ui generates a schema based on the inner properties of the MultipartFormDataInput instead of a button to upload the file.
I tried use a #FormParam annotation (to indicate that the providing parameter should be interpreted as file) along with the MultipartFormDataInput parameter, but then the app doesn't want to compile.
Question: Is there any solution/workaround to provide the button to upload the file in the swagger-ui?
The solution is removing #ApiParam from your apiFile argument and adding #ApiImplicitParam (which is not bound to Jax-RS and allows defining parameters manually) above the method :
#ApiImplicitParams({#ApiImplicitParam (value = "File to register.", required = true, dataType = "file", name = "apiFile", paramType="formData")})
The final solution
The final solution includes a selected answer, but instead of removing #ApiParam we should add #ApiParam(hidden = true). Why?
If we remove #ApiParam, there are two fields: apiId, body with the inner properties of the MultipartFormDataInput and the button to upload the file in the swagger-ui. This body field is a side effect. To fix this issue we should provide #ApiParam(hidden = true), then there are the field with apiId and the button to upload the file in the swagger-ui.
BTW: I tested below code for swagger-ui in 1.5.12 version.
#PUT
#Path("/apis/{id}/file")
#Consumes(MediaType.MULTIPART_FORM_DATA)
#Produces(MediaType.APPLICATION_JSON)
#ApiOperation(value = "Registers a file.", code = 201, nickname = "registerFile")
#ApiResponses(
value = {
#ApiResponse(code = 201, message = "File created.",
response = FileCreated.class),
#ApiResponse(code = 400, message = "Invalid parameters."),
#ApiResponse(code = 404, message = "API is not found.")})
#ApiImplicitParams(
#ApiImplicitParam(value = "File to register.", required = true, dataType = "file",
name = "apiFile", paramType = "formData"))
Response registerFile(
#ApiParam(value = "API ID.", required = true) #PathParam("id") String apiId,
#ApiParam(hidden = true) MultipartFormDataInput apiFile) throws AppException;

Rally: Get user _ref from RallyRestApi object created using ApiKey

I created a connection to rally using the ApiKey constructor.
Question is how do i find out the User "_ref" associated with this User ApiKey ?
rallyRestApi= new RallyRestApi(new URI(host), "myApiKey");
I tried following 2 test runs:
doing a blank query (i.e. without any setQueryFilter) on User object; it returns me all the users.
QueryRequest userRequest = new QueryRequest("User");
QueryResponse userQueryResponse = connection.query(userRequest);
JsonArray userQueryResults = userQueryResponse.getResults();
Getting owner from Workspace object >> This returns me the owner of the Workspace
You may get a current user:
GetRequest getRequest = new GetRequest("/user");
GetResponse getResponse = restApi.get(getRequest);
JsonObject currentUser = getResponse.getObject();
String currentUserName = currentUser.get("_refObjectName").getAsString();
String currentUserRef = currentUser.get("_ref").getAsString();
System.out.println("current user: " + currentUserName + currentUserRef);
I tested it with latest Rally API toolkit for Java.

Undefined merge field in google apps script

I have a Google Apps Script for a Google Spreadsheet based on a Google Form that clients fill out online. The script is triggered by OnFormSubmit and generates a pdf based on a Google Doc template and sends the pdf to me by email using MailApp.sendEmail.
This script has been working fine until recently. The script runs successfully but the pdf output is incorrect. It seems like fields that are left blank are now being ignored in the script and so my pdf output shows the value for the next non-blank field. Ugh!
Anybody know what's going on here?
Below is an example of my script:
var docTemplate = "1FZL4rVe0LLpvMtIsq_3-pwv5POllIsyYThjfemkbkfg";
var docName = "Travel Details";
function onFormSubmit(e) {
var last = e.values[1];
var first = e.values[2];
var order = e.values[3];
var date = e.values[4];
var gender = e.values[5];
var email = "example#gmail.com";
var copyId = DocsList.getFileById(docTemplate)
.makeCopy(docName+' for '+last + ', ' + first)
.getId();
var copyDoc = DocumentApp.openById(copyId);
var copyBody = copyDoc.getActiveSection();
copyBody.replaceText('keyLast', last);
copyBody.replaceText('keyFirst', first);
copyBody.replaceText('keyOrder', order);
copyBody.replaceText('keyDate', date);
copyBody.replaceText('keyGender', gender);
copyDoc.saveAndClose();
var pdf = DocsList.getFileById(copyId).getAs("application/pdf");
MailApp.sendEmail(email, subject, "", {htmlBody: office_message, attachments: pdf,
noReply:true});
DocsList.getFileById(copyId).setTrashed(true);
}
Example of the problem: If client leaves date field blank on the form, the gender value in the resulting pdf is put where the date value should be and the value for gender on the pdf shows "undefined".
Any ideas out there?
You should validate the values of all your variables.
if (last === undefined) {
last = 'No Data!'; //re-assign a different value
};
So, you are changing the value of the variable last if it somehow got set to undefined. That way, hopefully the pdf would still show the field.
If there is some bug that just showed up recently, you should report it as a bug. If everything was working fine, and now it's broken, Google may have changed something.
There might be something wrong with your code. I don't know. Have you looked under the "View" menu and the "Execution Transcript" to see if there are any errors? You should also use Logger.log statements: Logger.log('The value of last is: ' + last); to print output to the log. Then you can check what is actually going on.
I am no great coder but I use this script all the time to send pdf's I have never received an undefined if a field was missing. Typically if something is missing, the keygender is replaced with a blank spot and there is no error. In a spreadsheet, typically this means the columns were changed. It used to be timestamp(0), last(1), first(2), order(3), date(4), gender(5) and now their in a different order.
Try the below code it works
//commons errors -
//Triggers are not set
//spaces after Form questions
//e.values dont work when fields are not mandatory and left blank
//e.namedValues dont work for sending emails use e.values[#]
//place holder keys in template dont match
//spelling errors
//Note expect undefined error when de-bugging as values are not defined until form completed and submitted - run first with a small test form as per below
// Get Template
//from Google Docs and name it
var docTemplate = " "; // *** replace with new templae ID if new Template created***
var docName = "Test Script"; //replace with document name
// When Form Gets submitted
function onFormSubmit(e) {
//Get information from the form and set as variables
//var variablename = "static entry or form value"
//Note: var Variablename = e.namedValues["X"]; is taking the value from the spreadsheet by column name so update if spreadsheet or form questions change
//Additions to the form will be added to the end of the spreadsheet regardless of their position in the form
var Timestamp = e.namedValues["Timestamp"];
var full_name = e.namedValues["Name"];
var position = e.namedValues["Position"]
var contact_email = e.namedValues["Contact Email"];
var phone_number = e.namedValues["Telephone Number"];
// Get document template, copy it as a new doc with Name and email, and save the id
var copyId = DocsList.getFileById(docTemplate)
.makeCopy(full_name+' '+docName+' for ' +contact_email+' '+Timestamp)//Update or remove Variablename to create full doc Name
.getId();
// Open the temporary document
var copyDoc = DocumentApp.openById(copyId);
// Get the documents body section
var copyBody = copyDoc.getActiveSection();
// Replace place holder keys <<namedValues>> in template
//copyBody.replaceText('<<X>>', Variablename); Variables from above
//***Update if template is changed***
copyBody.replaceText('<<Timestamp>>', Timestamp);
copyBody.replaceText('<<Name>>', full_name);
copyBody.replaceText('<<Position>>', position);
copyBody.replaceText('<<Contact Email>>', contact_email);
copyBody.replaceText('<<Telephone Number>>', phone_number);
// Save and close the temporary document
copyDoc.saveAndClose();
// Convert temporary document to PDF by using the getAs blob conversion
var pdf = DocsList.getFileById(copyId).getAs("application/pdf");
{
// Add the data fields to the message
var s = SpreadsheetApp.getActiveSheet();
var columns = s.getRange(1,1,1,s.getLastColumn()).getValues()[0];
var message = " ";
// Only include form fields that are not blank
for ( var keys in columns ) {
var key = columns[keys];
if ( e.namedValues[key] && (e.namedValues[key] != "") ) {
message += key+ ' : '+ e.namedValues[key] + "<br>";
}
}}
// Attach PDF and send the email
//***Change the "To" email address when to form goes live***
var to = "youremail#gmail.com";
var senders_name = e.values[1]
var contact_email = e.values[3]
var subject = "Test";
var htmlbody = "text goes here"+
"<br> <br>"+message+
"<br> <br>Submitted By:"+
"<br> <br>"+full_name+
"<br>"+position+
"<br>"+contact_email+
"<br>"+phone_number+
"<br> <br>Generated by Hansmoleman for Compu-Global-Hyper-Mega-Net";
MailApp.sendEmail({
name: senders_name,
to: to,
cc: contact_email,
replyTo: contact_email,
subject: subject,
htmlBody: htmlbody,
attachments: pdf,
});
}