CSLibrary/Template.cs
/// <summary>
/// Create a Template by Flattening an Existing Document
/// </summary>
/// <param name="AccessToken"></param>
/// <param name="DocumentId">The ID of the Document to make a Template</param>
/// <param name="DocumentName">New Template Name</param>
/// <param name="ResultFormat">JSON, XML</param>
/// <returns>The ID of the new Template</returns>
Create a Template by Flattening an Existing Document
Create a Template by Flattening an Existing Document
public static dynamic Create(string AccessToken, string DocumentId, string DocumentName = "", string ResultFormat = "JSON")
        {
            var client = new RestClient();
            client.BaseUrl = new Uri(Config.ApiHost);
            var request = new RestRequest("/template", Method.POST)
                .AddHeader("Accept", "application/json")
                .AddHeader("Authorization", "Bearer " + AccessToken);
            dynamic reqObj;
            if (DocumentName != "")
            {
                reqObj = new { document_id = DocumentId, document_name = DocumentName };
            }
            else
            {
                reqObj = new { document_id = DocumentId };
            }
            request.RequestFormat = DataFormat.Json;
            request.AddBody(reqObj);
            var response = client.Execute(request);
            dynamic results = "";
            if (response.StatusCode == HttpStatusCode.OK)
            {
                results = response.Content;
            }
            else
            {
                Console.WriteLine(response.Content.ToString());
                results = response.Content.ToString();
            }
            if (ResultFormat == "JSON")
            {
                results = JsonConvert.DeserializeObject(results);
            }
            else if (ResultFormat == "XML")
            {
                results = (XmlDocument)JsonConvert.DeserializeXmlNode(results, "root");
            }
            return results;
        }
public static dynamic Create ( string AccessToken , string DocumentId , string DocumentName = " " , string ResultFormat = " " ) { var client = new RestClient ( ) ; client . BaseUrl = new Uri ( Config . ApiHost ) ; var request = new RestRequest ( " " , Method . POST ) . AddHeader ( " " , " " ) . AddHeader ( " " , " " + AccessToken ) ; dynamic reqObj ; if ( DocumentName != " " ) { reqObj = new { document_id = DocumentId , document_name = DocumentName } ; } else { reqObj = new { document_id = DocumentId } ; } request . RequestFormat = DataFormat . Json ; request . AddBody ( reqObj ) ; var response = client . Execute ( request ) ; dynamic results = " " ; if ( response . StatusCode == HttpStatusCode . OK ) { results = response . Content ; } else { Console . WriteLine ( response . Content . ToString ( ) ) ; results = response . Content . ToString ( ) ; } if ( ResultFormat == " " ) { results = JsonConvert . DeserializeObject ( results ) ; } else if ( ResultFormat == " " ) { results = ( XmlDocument ) JsonConvert . DeserializeXmlNode ( results , " " ) ; } return results ; }
Create a Template by Flattening an Existing Document
Create a Template by Flattening an Existing Document
The ID of the new Template
The ID of the new Template
AccessToken
string
None
DocumentId
string
The ID of the Document to make a Template
The ID of the Document to make a Template
DocumentName
string
New Template Name
New Template Name
ResultFormat
string
None