ReportingCloud

POST /v1/templates/upload

Endpoint

POST https://api.reporting.cloud/v1/templates/upload

Description

Stores a template in the template storage, where merge and the other methods find it by its name. The query names the template, and the body is the file as a Base64 string in a JSON string. The supported formats are Microsoft Word (.docx and .doc), Rich Text Format (.rtf) and TX Text Control (.tx), and the extension of the name must match the format of the file. An upload under a stored name replaces that template; names are matched regardless of case. See Managing Templates.

Warning

Template Storage Quota. Each successful upload under a new name counts 1 against the template storage quota. An upload that replaces a stored template doesn't count, and deleting a template frees its place. Plans and Licensing lists the quota of each plan.

Examples

Request:

curl -u username:password \
  -H "Content-Type: application/json" \
  -d "\"CAcBAA4AAAAAAAAAAAAA...==\"" \
  -X POST "https://api.reporting.cloud/v1/templates/upload?templateName=test.tx"

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, with the extension .doc, .docx, .rtf or .tx in any case and at most 207 characters. Existing files with the same filename will be overwritten. Filenames are not case-sensitive: a stored template whose filename differs only in case is overwritten too and keeps its stored filename.no

Request Payload

TypeValue
Base64 encoded stringA document encoded as a Base64 string and sent as a JSON string, in double quotes, with the Content-Type application/json. Supported document formats are .doc, .docx, .rtf and .tx, and the document must be in the format that the extension of templateName names.

Success Response

StatusDescription
201On success, the HTTP status code in the response header is 201 (Created). The response body contains no data.

Error Response

StatusDescription
400A 400 (Bad Request) is returned, if the extension of templateName is not .doc, .docx, .rtf or .tx, or if the template has a wrong format, isn't in the format of its extension or is corrupted.
403A 403 (Forbidden) is returned, if the user is not authorized or the template storage quota is exceeded. The same 403 ("Template quota exceeded") is returned for a templateName that has more than 207 characters or contains # or /.
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 POST. The Allow header of the response names POST.
411A 411 (Length Required) is returned, if the request has neither a body nor a Content-Length header.
415A 415 (Unsupported Media Type) is returned, if the request has a body but no Content-Type header, or a Content-Type such as text/plain that the endpoint doesn't read. Send Content-Type: application/json.
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, or if the request body is not a JSON string of valid Base64 data or templateName is empty.