Copying a Report Template to Other Workspaces
Our sample projects and report templates can help you learn the basics of working with our products.A report template can be uploaded to other Server workspaces through the REST API, in size-limited chunks.
Create the file, then append chunks.
How it works. Large templates are uploaded in ~90 KB chunks under one version key, so a report can be copied into any workspace over REST.
Create the file, then append chunks.
var chunks = SplitByteArrayIntoChunks(reportTemplateBytes, 90 * 1024);
// Create the template with the first chunk
var create = WebRequest.Create($"{RestUrl}/files");
create.Method = "POST";
create.Headers.Add("x-sti-SessionKey", sessionKey);
AddBody(create, new JObject {
new JProperty("Ident", "ReportTemplateItem"),
new JProperty("Name", reportTemplateName),
new JProperty("Resource", Convert.ToBase64String(chunks[0].ToArray())) });
var fileKey = /* ResultItems[0].Key */;
var versionKey = /* ResultVersionKey */;
// Append the remaining chunks
for (int i = 1; i < chunks.Count; i++)
{
var append = WebRequest.Create($"{RestUrl}/files/{fileKey}");
append.Method = "PUT";
append.Headers.Add("x-sti-SessionKey", sessionKey);
append.Headers.Add("x-sti-VersionKey", versionKey);
AddBody(append, new JObject { new JProperty("Resource", Convert.ToBase64String(chunks[i].ToArray())) });
}POST /fileswithIdent=ReportTemplateItem— create the template from its first base64 chunk.PUT /files/{fileKey}with thex-sti-VersionKey— append each further chunk to the same file.
How it works. Large templates are uploaded in ~90 KB chunks under one version key, so a report can be copied into any workspace over REST.