ReportingCloud

GET /v1/templates/info

Endpoint

GET https://api.reporting.cloud/v1/templates/info

Description

Returns the merge fields and merge blocks of a template in the template storage, to build the data a merge needs. The response lists the merge fields outside blocks, in the main text, headers and footers; the merge blocks with their own fields and the blocks nested in them; and the user document properties of the template. See Mail Merge.

Examples

Request:

curl -u username:password \
  -X GET "https://api.reporting.cloud/v1/templates/info?templateName=sample_invoice.tx"

Results:

{
	"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": "#"
		}
	],
	"userDocumentProperties": {}
}

The result is shortened to 1 of the 6 merge fields of the item block and 2 of the 33 merge fields at the root level.

Authorization

This endpoint requires a "ReportingCloud-APIKey" or a "Basic" user authorization to access the user account, data and templates. Only one of these two methods is required.

API Keys describes how to create an API key, and Authentication explains both header forms.

ReportingCloud-APIKey

Header fieldDescription
AuthorizationRequired. A valid ReportingCloud account is required. The Authorization field is constructed as follows: An API key needs to be generated in the portal or with PUT /v1/account/apikey. The authorization method and a space, "ReportingCloud-APIKey ", is then put before the actual API key string. For example: Authorization: ReportingCloud-APIKey oMDM4MrAqL9QEOpyzupnQW5NjvCNtvE5cVDaaLqxI

Basic

Header fieldDescription
AuthorizationRequired. A valid ReportingCloud account is required. The Authorization field is constructed as follows: The user name and password are combined into a string separated by a colon, for example username:password. The resulting string is encoded using the RFC2045-MIME variant of Base64, except not limited to 76 char/line. The authorization method and a space, "Basic ", is then put before the encoded string. For example: Authorization: Basic QWxhZGRpbjpPcGVuU2VzYW1l

Request Parameters

NameTypeValueOptional
templateNameStringThe filename of the template in the template storage whose information is returned. The name is matched case-insensitively.no

Success Response

StatusDescription
200On success, the HTTP status code in the response header is 200 (OK). The response body contains a ReportingCloud TemplateInfo object.

TemplateInfo

NameTypeValueOptional
templateNameStringThe template name as the request gives it. Since template names are matched case-insensitively, its case can differ from the name in the template storage.no
mergeBlocksList of ReportingCloud MergeBlock objectsContains the merge blocks at the root level of the template. A nested merge block is listed in the mergeBlocks of the block that contains it.no
mergeFieldsList of ReportingCloud MergeField objectsContains the merge fields at the root level of the template, outside of merge blocks, including those of headers and footers. A field that occurs more than once is listed once per occurrence.no
userDocumentPropertiesObjectThe user-defined (custom) document properties of the template, with the property names as keys and their values as String, Number or Boolean values. Date properties are left out. An empty object if the template has none.no

MergeBlock

NameTypeValueOptional
nameStringThe name of the MergeBlock.no
mergeBlocksList of ReportingCloud MergeBlock objectsContains the merge blocks nested in the merge block.no
mergeFieldsList of ReportingCloud MergeField objectsContains the merge fields of the merge block, outside of the merge blocks nested in it.no

MergeField

NameTypeValueOptional
dateTimeFormatStringSpecifies a string format which is applied to date / time values (the \@ switch of the field).no
nameStringThe name of the merge field.no
numericFormatStringSpecifies a string format which is applied to numeric values (the \# switch of the field).no
preserveFormattingBooleanSpecifies whether the formatting is preserved (the \* MERGEFORMAT switch of the field).no
textStringThe text the field shows in the template, such as «name».no
textAfterStringThe text after the field (the \f switch of the field).no
textBeforeStringThe text before the field (the \b switch of the field).no

Error Response

StatusDescription
400A 400 (Bad Request) is returned, if the template doesn't exist in the template storage or templateName is empty.
403A 403 (Forbidden) is returned, if the user is not authorized.
404A 404 (Not Found) is returned, if a required query parameter is missing.
405A 405 (Method Not Allowed) is returned, if the request uses another HTTP method than GET. The Allow header of the response names GET.
500A 500 (Internal Server Error) is returned, if the request has no Authorization header, an empty one or one that is not the authorization method, a space and the credentials.