I have been trying to create a new Dropbox Sign Template using Dropbox Sign Create Template API. Please see the C# code snippet below.
string content = "{\"client_id\":\"XXXXXXXXXXXXXXXXXXXXXXXXX\",\"file_urls\":[\"https://www.dropbox.com/s/ad9qnhbrjjn64tu/mutual-NDA-example.pdf?dl=1\"],\"title\":\"DocuSign_Template_001\",\"subject\":\"Complete with Docusign\",\"message\":\"Complete\",\"signer_roles\":[{\"name\":\"Meghan\",\"order\":0}],\"cc_roles\":null,\"merge_fields\":null,\"field_options\":null,\"form_fields_per_document\":[{\"document_index\":0,\"api_id\":\"11c7e79e-168b-4548-ad64-0c64e4a16ace\",\"name\":\"\",\"type\":\"signature\",\"x\":714,\"y\":57,\"width\":120,\"height\":30,\"required\":true,\"signer\":0,\"page\":1}],\"test_mode\":true}";
var requestContent = new StringContent(content, Encoding.UTF8, "application/json");
var response = await client.PostAsync("https://api.hellosign.com/v3/template/create", requestContent);
if (response.IsSuccessStatusCode)
{
string responseBody = await response.Content.ReadAsStringAsync();
}
else
{
string responseBody = await response.Content.ReadAsStringAsync();
//{"error":{"error_msg":"form fields are required","error_path":"form_fields_per_document","error_name":"bad_request"}}
}
The Create Template request fails with Status Code 400 and the following error message in response. {"error":{"error_msg":"form fields are required","error_path":"form_fields_per_document","error_name":"bad_request"}}
I have set the form fields in the json as described in the documentation below: https://developers.hellosign.com/api/reference/operation/templateCreate/
I do not want to use Dropbox Sign .NET SDK as it supports version >= .Net 6.0. Can someone please guide me how to fix this error.
Thanks!
Dropbox Support suggested to use the following Dictionary<string, string> collection. This created a new Dropbox Sign Template
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new
AuthenticationHeaderValue("Bearer", this.AccessToken);
var data = new Dictionary<string, string>
{
{ "client_id","XXXXXXXXXXXXXXXXXXXXXXXXXX"},
{ "form_fields_per_document[0][document_index]", "0"},
{ "form_fields_per_document[0][type]", "signature"},
{ "form_fields_per_document[0][api_id]", "sign_1"},
{ "form_fields_per_document[0][name]", ""},
{ "form_fields_per_document[0][height]", "60"},
{ "form_fields_per_document[0][width]", "220"},
{ "form_fields_per_document[0][x]", "230"},
{ "form_fields_per_document[0][y]", "15"},
{ "form_fields_per_document[0][required]", "true"},
{ "form_fields_per_document[0][page]", "1"},
{ "form_fields_per_document[0][signer]", "0"},
{ "file_urls[0]", "https://www.dropbox.com/s/ad9qnhbrjjn64tu/mutual-NDA-example.pdf?dl=1"},
{ "signer_roles[0][name]", "Client"},
{ "signer_roles[0][order]", "0"},
{ "signer_roles[1][name]", "Witness"},
{ "signer_roles[1][order]", "1"},
{ "cc_roles[0]", "Manager"},
{ "title", "DocuSign_Template_006"},
{ "subject", "Please sign this document" },
{ "message", "For your approval" },
{ "test_mode", "true"}
};
FormUrlEncodedContent requestContent = new FormUrlEncodedContent(data);
var response = await client.PostAsync("https://api.hellosign.com/v3/template/create", requestContent);
}