Imports a creative template from an XML file, always creating it as a new template regardless of any existing ID in the XML.
Reference
POST https://YOUR-NETWORK-DOMAIN/rest-api/template/import-as-new.do
Imports a creative template from an XML file, always creating it as a new template regardless of any existing ID in the XML. The template ID, unique ID, and version are reset before saving. Requires CREATE permission on templates.
import fs from 'node:fs/promises';
const form = new FormData();
form.append('file', new Blob([await fs.readFile('template.xml')]), 'template.xml');
const response = await fetch('https://YOUR-NETWORK-DOMAIN/rest-api/template/import-as-new.do', {
method: 'POST',
headers: { 'X-Api-Key': 'YOUR_API_KEY' },
body: form,
});
console.log(await response.json());
Java Request
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://YOUR-NETWORK-DOMAIN/rest-api/template/import-as-new.do"))
.header("X-Api-Key", "YOUR_API_KEY")
// multipart upload: build the body with your HTTP library of choice
.method("POST", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
C# Request
using var client = new HttpClient();
var request = new HttpRequestMessage(new HttpMethod("POST"), "https://YOUR-NETWORK-DOMAIN/rest-api/template/import-as-new.do");
request.Headers.Add("X-Api-Key", "YOUR_API_KEY");
var form = new MultipartFormDataContent();
form.Add(new ByteArrayContent(File.ReadAllBytes("template.xml")), "file", "template.xml");
request.Content = form;
var response = await client.SendAsync(request);
Console.WriteLine(await response.Content.ReadAsStringAsync());
Go Request
package main
import (
"fmt"
"io"
"net/http"
)
func main() {
req, _ := http.NewRequest("POST", "https://YOUR-NETWORK-DOMAIN/rest-api/template/import-as-new.do", nil)
req.Header.Set("X-Api-Key", "YOUR_API_KEY")
// multipart upload: build the body with mime/multipart
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
out, _ := io.ReadAll(res.Body)
fmt.Println(string(out))
}