Products Technologies Demo Docs Blog Support Company

New ReportingCloud Endpoint: Retrieving Template Information Including Contained MergeFields and the MergeBlock Structure

We just released a new endpoint to the ReportingCloud Web API: http://api.reporting.cloud/v1/templates/info This endpoint returns information about a template located in the template storage. It returns a JSON structure with the template name, the contained merge fields, the nested merge block structure and included merge fields of the merge blocks. The following sample CURL shows the usage and the return value: The wrappers implement a new TemplateInfo object that returns the merge block…

New ReportingCloud Endpoint: Retrieving Template Information Including Contained MergeFields and the MergeBlock Structure

We just released a new endpoint to the ReportingCloud Web API:

http://api.reporting.cloud/v1/templates/info

This endpoint returns information about a template located in the template storage. It returns a JSON structure with the template name, the contained merge fields, the nested merge block structure and included merge fields of the merge blocks.

The following sample CURL shows the usage and the return value:

curl -u username:password \
  -X GET "https://api.reporting.cloud/v1/templates/info?templateName=sample_invoice.tx
{
        "templateName": "sample_invoice.tx",
        "mergeBlocks": [
                {
                        "name": "item",
                        "mergeFields": [
                                {
                                        "dateTimeFormat": "",
                                        "name": "qty",
                                        "numericFormat": "",
                                        "preserveFormatting": false,
                                        "text": "«qty»",
                                        "textAfter": "",
                                        "textBefore": ""
                                }
                        ],
                        "mergeBlocks": []
                }
        ],
        "mergeFields": [
                {
                        "dateTimeFormat": "",
                        "name": "yourcompany_companyname",
                        "numericFormat": "",
                        "preserveFormatting": false,
                        "text": "«YOURCOMPANY_COMPANYNAME»",
                        "textAfter": "",
                        "textBefore": ""
                },
                {
                        "dateTimeFormat": "",
                        "name": "invoice_no",
                        "numericFormat": "",
                        "preserveFormatting": false,
                        "text": "«invoice_no»",
                        "textAfter": "",
                        "textBefore": "#"
                }
        ]
}

The wrappers implement a new TemplateInfo object that returns the merge block and merge field structure like in this sample:

using System;
using System.Collections.Generic;
using System.Drawing;
using TXTextControl.ReportingCloud;

class RCSamples
{
    public static void GetTemplateThumbnails(string templateName)
    {
        ReportingCloud rc = new ReportingCloud(
            "username",
            "password",
            new Uri("https://api.reporting.cloud"));

        try
        {
            TemplateInfo templateInfo = rc.GetTemplateInfo(sTempFilename);
            Console.WriteLine(templateInfo.TemplateName);
        }
        catch (Exception e)
        {
            Console.WriteLine("An error occurred: " + e.Message);
        }
    }
}
sample_invoice.tx

This new method allows you to retrieve the contained merge fields of a template. Consider the following scenario: You would like to create an HTML form with input elements based on merge fields of a template. Using the templates/info endpoint, you can loop through all fields in order to create input form elements for user input. After the users completed this HTML form, you can merge back the data into the template in order to create a resulting document.

Start today with ReportingCloud and sign up for a free trial account.

Happy coding!

Stay in the loop!

Subscribe to the newsletter to receive the latest updates.

Cloud

Are we moving to the cloud? This question is changing from "if" to "when" and "how". Text Control ReportingCloud brings complete reporting functionality to the cloud so all developers can use it, irrespective of the platform or language they're using. Its highly RESTful API can be used to merge Microsoft Word compatible templates with JSON data from all clients including .NET, Javascript, PHP, Node.JS, jQuery, Ruby, Python, Android, Java and iOS.

See Cloud products

Related Posts

CloudReportingRelease

ReportingCloud Monthly Payment Available

We just released ReportingCloud monthly subscriptions that will be auto-renewed, if not cancelled.


CloudReleaseReportingCloud

ReportingCloud: Setting the Culture for Date and Currency Fields

We just released a new property to define the culture for the merge process to handle date and currency field values.


ASP.NETCloudConference

Visit Text Control at BASTA! 2017

Next week, we are exhibiting at the 20th anniversary edition of BASTA!, one of the largest .NET focused developer conferences in Germany.


CloudConferenceMail Merge

More Impressions from DWX Developer Week 2017

The DWX Developer Week 2017 was a huge success. We really enjoyed the powerful atmosphere talking to so many enthusiastic developers about our products, technologies and services. On the last day,…


CloudConferenceMail Merge

DWX Developer Week 2017: First Impressions

We are currently exhibiting at Germany's largest conference: DWX Developer Week. We are giving away our Text Control yo-yos, raffling off an XBox One and talking about our reporting libraries, our…