Use fields from a template DocuSign - c#

I want to make a simple application C# with docusign.
I created a template on the site with several fields that the user will have to fill in. The application simply chooses the email address of the candidate.
I do like this for create my Envelope :
TemplateRole tRoleSigner = new TemplateRole();
tRoleSigner.Email = DSConfig.Signer1Email;
tRoleSigner.Name = DSConfig.Signer1Name;
tRoleSigner.RoleName = "Candidat";
TemplateRole tRoleCC = new TemplateRole();
tRoleCC.Email = DSConfig.Cc1Email;
tRoleCC.Name = DSConfig.Cc1Name;
tRoleCC.RoleName = "EnCopie";
List<TemplateRole> rolesList = new List<TemplateRole>() { tRoleSigner, tRoleCC };
EnvelopeDefinition envelopeDefinition = new EnvelopeDefinition
{
EmailSubject = "Signatures des documents relatifs à une promesse d'embauche",
TemplateRoles = rolesList,
TemplateId = DSConfig.TemplateID,
Status = "sent"
};
I tested but the fields do not appear on the document ...
However if I directly use the template via docusign the fields are there!
I know that we can create a tab in the C # code but I want to use the fields defined on the site!
I think I'm missing something ...

Without more information, including logs and IDs can't be sure what is the issue.
Possibilities:
RoleName is wrong/mismatch. Must be the one in the template that you use the ID for.
Fields are using anchor tags that are not found in document.
Template is in production and you are using developer account.
You can also try the web app ("directly") again and enable to see the API logs. The web app uses the same API that you do, and this way you can see exactly how it's done.

Related

Microsoft Graph API - user extension data in C#

I have an Azure AD B2C directory with some users in it. I have been using the Microsoft Graph API and through both https://developer.microsoft.com/en-us/graph/graph-explorer and PostMan I have been able to create and modify users along with including an extension attribute (eg: extension_[guid in our tenant]_ContactMethod) - details passed in json in the body of the request in PostMan.
That is fine, however I need to be albe to do the same in C#. I can successfully create the user without specifying any extensions:
GraphServiceClient graphClient = new GraphServiceClient(authProvider);
var user = new User
{
AccountEnabled = true,
DisplayName = "John Smith",
MailNickname = "JohnSimth",
UserPrincipalName = "JohnSmith#[tenant].onmicrosoft.com",
PasswordProfile = new PasswordProfile
{
ForceChangePasswordNextSignIn = true,
Password = "[Randomly Generated Password]"
}
//[Extension attributes to add here]
};
await graphClient.Users.Request().AddAsync(user);
However I need to be able to specify some extension attributes when creating / modifying the user in C#. How do I do this?
You cannot directly add extensions at the time of creation according to this limitations document.
After creating the user, you need to create a separate request that hits the extensions endpoint as shown in the below code and this adds these extension details to the user.
var extension = new OpenTypeExtension
{
ExtensionName = "{ExtensionName}",
AdditionalData = new Dictionary<string, object>
{
{"FirstEmail", "abc#yahoo.com"},
{"SecondEmail" , "xyz#yahoo.com"}
}
};
await graphClient.Users["{UserId}"].Extensions
.Request()
.AddAsync(extension);
So just after user creation, get that userid and use it to hit extensions endpoint as shown in the above code.

Docusign API attach supplemental documents

How does one go about sending a supplemental document along with the document to sign?
the use case:
We are sending a contract for the user to sign, and would like to send the person som startup/welcome information aswell.
What ive tried:
Creating the attachment
Attachment attachment = new Attachment()
{
data = Convert.ToBase64String(docStorageDto.DocumentBlob),
name = ConversionUtil.MakeLegalFileName(docStorageDto.OrigFilename),
attachmentId = displayIndex.ToString() + index,
attachmentType= "pdf"
};
Tried to add it to the envelope
envelopeDefinition.attachments = new List<Attachment>(){ attachment };
envelopeDefinition.envelopeAttachments = new List<Attachment>(){ attachment };
Tried to add it to the "Signer" object
RecipientAttachment att = new RecipientAttachment()
{
data = attachment.data,
name = attachment.name,
attachmentId = attachment.attachmentId,
attachmentType = attachment.attachmentType
};
recipientSigner.recipientAttachments = new List<RecipientAttachment>(){att};
All with no luck, fields does not seem to be used? Where does one need to add the attachments/supplemental documents?
For future reference, Larry K is right.
supplemental documents does not use the attachment properties, but is just sent as a regular document. What i needed to set for it not to be included in the combined document etc. was to set these properties on the "Document" object:
includeInDownload = "false";
display = "modal";
A supplemental document does not use an attachment object.
To add a supplemental document to an envelope:
Read the docs.
Create a document object, same as for any other document.
Set the signerMustAcknowledge attribute of the document object to one of:
no_interaction No recipient action is required.
view The recipient is required to view the document.
accept The recipient is required to accept the document by selecting accept during signing, but is not required to view the document.
no_interaction No recipient action is required.

Sparkpost C# API add attachments to templates

I've been going thumbing through the documentation and searching the internet to find documenation on how to add attachments to created templates. I'm using darrencauthon's CSharp-Sparkpost to handle the API calls. So far what I have is not working. Does anyone have a working solution (possible?) or a better solution for C#? I'm not opposed to using a different library. This is the link to CSharp-Sparkpost
Here's what I've got so far:
var t = new Transmission();
t.Content.From.Email = "from#thisperson.com";
t.Content.TemplateId = "my-template-email";
new Recipient
{
Address = new Address { Email = recipient }
}
.Apply(t.Recipients.Add);
new Attachment
{
Data = //CSVDATA,
Name = "Table.csv",
Type = "text/csv"
}.Apply(t.Content.Attachments.Add);
var client = new SparkPost.Client(Util.GetPassword("sparkpostapikey"));
client.Transmissions.Send(t).Wait();
I've verified that I can send this attachment without a template and also verified that I can send this template without the attachment. So... the Email is getting sent; however, the content received is only the template and substitution data. No attachment with the template email.
Using Darren's library, and combining the requirements for my project, this is the solution I've come up with. I'm just making an additional API call to grab the template Html so I can build the transmission without having to send the template_id. Still using the CSharp-Sparkpost library to make all of the calls. I modified Darren's example SendInline program as such:
static async Task ExecuteEmailer()
{
var settings = ConfigurationManager.AppSettings;
var fromAddr = settings["fromaddr"];
var toAddr = settings["toaddr"];
var trans = new Transmission();
var to = new Recipient
{
Address = new Address
{
Email = toAddr
},
SubstitutionData = new Dictionary<string, object>
{
{"firstName", "Stranger"}
}
};
trans.Recipients.Add(to);
trans.SubstitutionData["firstName"] = "Sir or Madam";
trans.Content.From.Email = fromAddr;
trans.Content.Subject = "SparkPost sending attachment using template";
trans.Content.Text = "Greetings {{firstName or 'recipient'}}\nHello from C# land.";
//Add attachments to transmission object
trans.Content.Attachments.Add(new Attachment()
{
Data = Convert.ToBase64String(System.IO.File.ReadAllBytes(#"C:\PathToFile\ExcelFile.xlsx")),
Name = "ExcelFile.xlsx",
Type = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
});
Console.Write("Sending mail...");
var client = new Client(settings["apikey"]);
client.CustomSettings.SendingMode = SendingModes.Sync;
//retrieve template html and set Content.Html
var templateResponse = await client.Templates.Retrieve("template-email-test");
trans.Content.Html = templateResponse.TemplateContent.Html;
//Send transmission
var response = client.Transmissions.Send(trans);
Console.WriteLine("done");
}
Oh actually, I see now -- you are talking about adding attachments to templates, not attachments.
My answer to that is that back when I developed this library, attachment on templates was not supported by SparkPost itself.
My library allows you to try it, but that's because every template and non-template emails are considered "transmissions." So if you create a transmission, it has the option of adding attachments... but if you send the transmission with a template id, the attachment is ignored.
I could throw an error, or somehow design the API around this limitation, but what if they stopped ignoring the attachment but my library threw an error? I designed the library for flexibility as the SparkPost web API grew, and I didn't want my library to get in the way.
If you want to test if you're sending the attachment right, send your transmission without a transmission id, and instead with a subject and email body. If the email goes through and you get an attachment, then you know it's because of this template/attachment restriction from SparkPost.
NOTE: I'm putting this answer on Stack Overflow, and it's possible that this dated message will no longer be valid in the future.
I'm Darren Cauthon, the primary author of this library.
I have attachment support in my acceptance tests, which are run before each release. The link is below, but the code should be as simple as:
// C#
var attachment = File.Create<Attachment>("testtextfile.txt");
transmission.Content.Attachments.Add(attachment);
https://github.com/darrencauthon/csharp-sparkpost/blob/3a8cb1efbb8c9a0448c71c126ce7f88759867fb0/src/SparkPost.Acceptance/TransmissionSteps.cs#L56

C# sharing content on Facebook

First thing first, I never used SDK before and I don't know what does token mean. I am searching for the most simple solution, if possible without SDK, without token, without FB App.
I have a button in my C# application and when the user clicks on it I want a popup window where the user can login to Facebook or if he is logged in he can push the share button in order to share the predefined content.
While searching on the internet I found this code:
var client = new FacebookClient("my_access_token");
dynamic parameters = new ExpandoObject();
parameters.message = "Check out this funny article";
parameters.link = "http://www.example.com/article.html";
parameters.picture = "http://www.example.com/article-thumbnail.jpg";
parameters.name = "Article Title";
parameters.caption = "Caption for the link";
parameters.description = "Longer description of the link";
parameters.actions = new {
name = "View on Zombo",
link = "http://www.zombo.com",
};
parameters.privacy = new {
value = "ALL_FRIENDS",
};
parameters.targeting = new {
countries = "US",
regions = "6,53",
locales = "6",
};
dynamic result = client.Post("me/feed", parameters);
But this example uses Facebook SDK and it needs token. I want a simple solution, without SDK, without FB APP. I want a simple popup with predefined text.
Is there any solution?
An access token is an opaque string that identifies a user, app, or page and can be used by the app to make graph API calls.
Access Tokens identifies an app ,user or page
Without creating an app from facebook and getting a token you cannot proceed in this case(c# application).

Retrieving all Users using Google Apps Provisioning API?

I am trying to retrieve all users in domain but it's never work. I never got any error in my code.
I am adding as reference Google.GData.Apps.dll in my project. I am using Google Apps Provisioning API. I am referring these link https://developers.google.com/google-apps/provisioning/
Code :-
string domain = #"<domain name>";
string subs = #"<Authorization code>";
AppsService appService = new AppsService(domain, subs);
// appService.CreateUser("john.jain","James","anderson","james#1234");
// appService.DeleteUser("Amitesh");
appService.RetrieveAllUsers();
The following works for me - RetrieveAllUsers() returns a UserFeed object containing all users. Note that I am using a different constructor for the apps service (using username/password credentials and not OAuth).
this.appsService = new AppsService(credential.Domain, credential.Username, credential.Password);
UserFeed userFeed = this.appsService.RetrieveAllUsers();
// Selecting all users except domain super administrators.
var usernamesInDomain =
(from UserEntry user in userFeed.Entries
where user.Login.Admin != true
select user.Login.UserName).ToList();
What does the returned UserFeed object contain in your case?
This is my solution :-
Google.GData.Apps.UserFeed s = appService.RetrieveAllUsers();
foreach (UserEntry s1 in s.Entries)
{
string username = s1.Login.UserName.ToString();
}

Categories

Resources