I want to reuse a DocuSign template for multiple recipients in the same envelope. The template is rather simple; it has a few signing and date signed blocks.
The recipients will have different routing orders. From what I've seen, my API request needs to have the Routing Order and Role Name match the DocuSign template. If the role name and routing order don't match, I end up with an empty role (which has all of the signing blocks) on the envelope. I've also tried "merge roles on draft." The empty role will be merged into the second recipient, but I lose all of the template's signing blocks for that recipient.
Is there a way to use a template but modify the definition of the template recipient role? Ideally, I'd like to use the exact same template but change the routing order of that role for the second recipient. I'd like to avoid creating new templates in DocuSign since I could end up with many combinations.
I'd like to accomplish (UPDATE):
I want to use the same template two times in a single envelope. Each recipient will be assigned to an individual copy of the template. The final envelope should have two recipients, two documents, and each recipient will only have access and visibility to their document.
The issue is that the template's role defines the routing order. The routing order of "1" is applicable for the first recipient using the template, but the second recipient needs a routing order of "2." (The template's role expects a routing order of "1" in all cases, but I want that value to be a "2" for the second recipient.)
Example Template Information:
Template Name (for example purposes): Test Template #1
Role Name: Applicant 1
Routing Order: 1 (if I don't define the routing order, DocuSign treats it as a "1" anyways)
Example Request:
EnvelopeDefinition envDef = new EnvelopeDefinition();
var signer1 = new Signer()
{
RecipientId = "1",
Name = "First User 1",
RoleName = "Applicant 1",
Email = "fakeemail1#email.com",
RoutingOrder = "1"
};
var signer2 = new Signer()
{
RecipientId = "2",
Name = "First User 2",
RoleName = "Applicant 1",
Email = "fakeemail2#email.com",
RoutingOrder = "2"
};
envDef.CompositeTemplates = new List<CompositeTemplate>();
var composite1 = new CompositeTemplate()
{
ServerTemplates = new List<ServerTemplate>()
{
new ServerTemplate("1", "Test Template #1 TEMPLATE_ID_GUID_HERE")
},
InlineTemplates = new List<InlineTemplate>()
{
new InlineTemplate()
{
Sequence = "1",
Recipients = new Recipients()
{
Signers = new List<Signer>()
{
signer1
}
}
}
}
};
var composite2 = new CompositeTemplate()
{
ServerTemplates = new List<ServerTemplate>()
{
new ServerTemplate("2", "Test Template #1 TEMPLATE_ID_GUID_HERE")
},
InlineTemplates = new List<InlineTemplate>()
{
new InlineTemplate()
{
Sequence = "2",
Recipients = new Recipients()
{
Signers = new List<Signer>()
{
signer2
}
}
}
}
};
envDef.CompositeTemplates.Add(composite1);
envDef.CompositeTemplates.Add(composite2);
envDef.EnforceSignerVisibility = "true";
// Code to send envelope
Note: Also, I'm using composite templates since our envelopes will likely have various combinations of templates and uploaded documents.
Thank you!
This can be achieved by passing a query parameter - change_routing_order=true while creating an envelope. So endpoint for creating envelope will be
https://{{EnvironmentVal}}/restapi/v2/accounts/{{AccountIdVal}}/envelopes?change_routing_order=true
and body of the request will be
Req Body:
where same templateId - 076d9062-cfc7-408b-a47f-88c4b74af62b is used with same RoleName but diff routing order and diff Signer details
{
"compositeTemplates": [
{
"inlineTemplates": [
{
"recipients": {
"signers": [
{
"email": "email+internal#gmail.com",
"name": "John Doe",
"recipientId": "1",
"roleName": "Signer1",
"routingOrder": "1"
}
]
},
"sequence": "2"
}
],
"serverTemplates": [
{
"sequence": "1",
"templateId": "076d9062-cfc7-408b-a47f-88c4b74af62b"
}
]
},
{
"inlineTemplates": [
{
"recipients": {
"signers": [
{
"email": "email+internal2#gmail.com",
"name": "John Doe2",
"recipientId": "2",
"roleName": "Signer1",
"routingOrder": "2"
}
]
},
"sequence": "2"
}
],
"serverTemplates": [
{
"sequence": "1",
"templateId": "076d9062-cfc7-408b-a47f-88c4b74af62b"
}
]
}
],
"status": "sent"
}
Related
In the Norway they have a register of organisations (brreg.no), which you can access through a webservice. If an organisation owns one or more other organisations, you can also access a list of those.
Now my problem is this: I would like to create a class for the parrent organisation and populate it with DataContractJsonSerializer. That par is easy. What I would also like to do, is to have a List<ChildrenOrganisation> in the parent class. This would also be easy, if the parrent and children organisation were in the same JSON file. But they are not. Is there a way to work around this, perhaps merging two different Streams?
Here is my how I get the HTTP Web Response:
public async Task GetHttpWebRespsoneAsJson(bool isSubOrganisation)
{
string href;
string requestString;
// Set the request string, depending on whether or not it is a sub-organisation
if (isSubOrganisation)
{
href = "http://data.brreg.no/enhetsregisteret/underenhet.json?page=0&size=100&$filter=overordnetEnhet+eq+{0}";
requestString = String.Format(href, organisationNumber);
}
else
{
href = "http://data.brreg.no/enhetsregisteret/enhet/{0}.json";
requestString = String.Format(href, organisationNumber);
}
// Create the HTTP request, using the input parameters
WebRequest httpRequest = WebRequest.Create(requestString);
// Get the respone of the HTTP request
httpResponse = await httpRequest.GetResponseAsync();
// Get the statuscode (hopefully "OK")
httpStatus = ((HttpWebResponse)httpResponse).StatusCode;
}
Here is my implementation of DataContractJsonSerializer:
public CompanyModel GetCompany()
{
CompanyModel company = new CompanyModel();
using (Stream httpDataStream = httpResponse.GetResponseStream())
{
DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(CompanyModel));
company = (CompanyModel)ser.ReadObject(httpDataStream);
httpDataStream.Close();
}
return company;
}
The parent organisation simplifed (see an actual example here):
{
"organisationId": 123,
"name": "Parent Organisation",
"address": {
"streetname": "Electric Avenue",
"number": 42,
"city": "Los Angeles"
}
}
The list of children organisations simplified (see an actual example here):
"organisations": [
{
"organisationId": 456,
"parentOrganisation": 123,
"name": "Children Organisation 1",
"address": {
"streetname": "Sunset Boulevard",
"number": 69,
"city": "San Fransisco"
}
},
{
"organisationId": 789,
"parentOrganisation": 123,
"name": "Children Organisation 2",
"address": {
"streetname": "Ocean Drive",
"number": 13,
"city": "Miami"
}
}
]
I am unable to get word substitution to work consistently with sendgrid v3 api in c#. Sometimes the tags will be substituted, other times they will not. I am at a loss as to what causes this. Can anyone see any obvious errors in my code?
String apiKey = "KEY";
dynamic sg = new SendGridAPIClient(apiKey);
Email from = new Email("info#example.com");
String subject = "Hello World from the SendGrid CSharp Library";
Email to = new Email("example#gmail.com");
Content content = new Content("text/html", " ");
to.Name = "Joe";
Mail mail = new Mail(from, subject, to, content);
mail.TemplateId = "dfea45f3-d608-4860-9f38-c7d444qwrqwc1f";
Personalization subs = new Personalization();
subs.AddTo(to);
subs.AddSubstitution("*|url|*", "http://asdasdasd.com");
subs.AddSubstitution("*|username|*", "MrUsername");
mail.AddPersonalization(subs);
dynamic response = sg.client.mail.send.post(requestBody: mail.Get());
Remove the Personalization and add the following
mail.Personalization[0].AddSubstitution("*|url|*", "http://asdasdasd.com");
mail.Personalization[0].AddSubstitution("*|username|*", "MrUsername");
or see code samples here
I have found the issue my side. I think yours is the same. When you look at mail object before sending you will find there are 2 personification items in the array. You do this subs.AddTo(to); then later on mail.AddPersonalization(subs); This creates 2 email to in the personalization array - my example of the wrong payload was:
{
"from": {
"email": "no-reply#chromasports.com"
},
"subject": "",
"personalizations":
[
{
"to": [{
"email": "email#gmail.com"
}]
},
{
"to": [{
"email": "email#gmail.com"
}],
"substitutions": {
":token": "http://alabala.com/auth/reset-password#token=or514rqHTeLjtjlN6WRppOu53yJJ64nSzcK86GF6Ite2BaZRa58YPMfTmM0wzQs4tMLbHy8YlpieDVBae1aD99TKnMh7wYNOE2nmu8gWePQoZiWhbFLomVBvApHA1fuxIxQ1elui2QXAmGPtwDdvVOgvAiSF3HQteuvFwP5kXUnXXEeddYLIUHqJCDrATiOsSgxvcpKmhXhrhx78ns49f4hakGlLMncNgBuMGmL3wCduY9f22hjCs9tbIPq5h5V"
}
}
],
"content": [{
"type": "text/html",
"value": "\u003chtml\u003e\u003cbody\u003eHTML content\u003c/body\u003e\u003c/html\u003e"
}],
"template_id": "unique id"
}
'
Check your payload and to fix it try mail.AddPersonalization[0] = subs; Hope this solves your issue
I am working with EF/Web API. I am new to EF. I want to get a list of users from the aspnetusers table along with the user roles.
For instance, the sample JSON that I would like to see.
[
{
"UserId": "sample string 1",
"Enabled": true,
"Email": "sample string 3",
"Username": "sample string 4",
"Roles": [
{
"Id": "safdsdafadsf",
"Name": "Reader"
},
{
"Id": "sdfskjadhf",
"Name": "Writer"
}
]
}]
I followed the advise on this thread
ASP.NET 4.5 WebAPI to return list of users
This works for getting the aspnetuser table info, but when I try to add in roles, I get errors on the user.Roles
Message "There is already an open DataReader associated with this Command which must be closed first." I am using the default user management scheme that is created when building a new Web API project in Visual Studio.
Here is my code.
public IEnumerable<UserListBindingModel> GetUsers()
{
List<UserListBindingModel> userList = new List<UserListBindingModel>();
foreach (ApplicationUser user in UserManager.Users)
{
userList.Add(new UserListBindingModel
{
UserId = user.Id,
Enabled = user.enabled,
Username = user.UserName,
Email = user.Email,
Roles = user.Roles
});
}
return userList;
}
I am trying to post a new item creation to a test store via C#, but I'm not sure how the syntax should read. Square Connect API requires at least one variation for new item creation, but I'm not sure how to add that to the JSON body. Here is what I have, but I'm not sure how to complete it.
var client = new RestSharp.RestClient();
var post = new RestRequest("https://connect.squareup.com/v1/me/items", Method.POST);
post.RequestFormat = DataFormat.Json;
post.AddHeader("Authorization", String.Format("Bearer {0}", testtoken));
post.AddBody(new { name = testname, variations = ???? });
This code works, but returns a response of an item must include at least one variation. I realize that, but do not know how to write it, or if it is even possible.
I am not opposed to going a different route.
Edited to add a sample request body from the Square documentation:
{
"name": "Milkshake",
"description": "It's better than yours",
"visibility": "PRIVATE",
"category_id": "36ac7016-3a4e-4934-81f1-9057ac613f2y",
"variations": [
{
"name": "Small",
"pricing_type": "FIXED_PRICING",
"price_money": {
"currency_code": "USD",
"amount": 400
},
"sku": "123"
}
]
}
Something like this should serialize to JSON in the correct format:
post.AddBody(new {
name = testname,
variations = new object[] {
new {
name = "Small",
pricing_type = "FIXED_PRICING",
price_money = new {
currency_code = "USD",
amount = 400
}
}
},
sku = "123"
});
I have some JSON which represents settings for an application. A simplified example is shown below:
{
"data": {
"app_settings": {
"jbofmngeodhmdlnicmlnfhjmmbdbcokh": {
"title": "app 1",
"description": "desc 1",
"custom_app_setting_stored_below": "asd",
"cust1": 3,
"cust2": false
},
"esghmzlnxcfpnrkbokmvgtjmcaknysdb": {
"title": "app 2",
"description": "desc 2",
"custom_app_setting_stored_below": "asd",
"cust8": 12,
"cust10": "11/25/2013",
"cust11": "nothing",
"cust12": true,
"cust13": 3
}
}
}
}
The application can have extensions (represented in the settings by the long random strings of letters), and each extension can have its own custom settings beneath it.
I can manually blacklist an extension by adding a "blacklist" property for an extension and setting it to true. This will prevent the extension from being loaded by the application.
Here's an example of a blacklisted extension:
"jbofmngeodhmdlnicmlnfhjmmbdbcokh": {
"title": "app 1",
"description": "desc 1",
"custom_app_setting_stored_below": "asd",
"cust1": 3,
"cust2": false,
"icons": {
"128": "text21456.gif",
"16": "text21456.gif",
"48": "text21456.gif"
},
"plugins": [
{
"path": "plugins/ApiPlugin.dll",
"public": true
},
{
"path": "plugins/mp.dll",
"public": true
},
{
"path": "plugins/Plugin.dll",
"public": true
}
],
"blacklist": true
}
Now I want to be able to blacklist an extension programmatically.
In C#, I'm searching for a specific extension like this:
var data = json["data"];
var app_settings = data["app_settings"];
var a = app_settings.Children().ToList();
foreach (var b in a)
{
if (b.ToString().ToLower().Contains("extensionname"))
{
JToken ext = b;
// need to add blacklist property here
}
}
So for example, if the search matches, I might have something like this in ext:
"jbofmngeodhmdlnicmlnfhjmmbdbcokh": {
"custom_extension_property_1": "value 1",
"custom_extension_property_2": "value 2"
}
How do I add a "blacklist" boolean property in those extension settings so it will look like this?
"jbofmngeodhmdlnicmlnfhjmmbdbcokh": {
"custom_extension_property_1": "value 1",
"custom_extension_property_2": "value 2",
"blacklist": true
}
I don't think this will work:
bool blacklist = true;
ext.AddAfterSelf(blacklist);
or this:
someobject o = new someobject() {
blacklist = true;
};
ext.AddAfterSelf(o);
What am I missing?
From your question it looks like you're trying to find a particular extension by its title, and then add a "blacklist" property to that extension's settings if the title is found. You can do that like this:
string extensionNameToBlacklist = "app 1";
var data = json["data"];
var app_settings = data["app_settings"];
foreach (JProperty extensionProperty in app_settings)
{
JObject extensionObject = (JObject)extensionProperty.Value;
if ((string)extensionObject["title"] == extensionNameToBlacklist)
{
extensionObject.Add("blacklist", true);
}
}
Fiddle: https://dotnetfiddle.net/tESgmB
I think the part you were missing is that JToken is just a base class for more specific token classes like JObject and JProperty. Sometimes you have to cast the JToken to be able to access methods and properties that are specific to that class, like the Add method on JObject. (If you have a token and you don't know what kind it is, you can check its Type property to find out.)