Upload model files

Allows multiple files to be uploaded, which are used to create new document classes or groups. The maximum file size that can be accepted is 250 MB.

Syntax.
PUT ​/model/build
Table 1. Uploading model files requirements
Property Data type Description
apiKey header String Required. To authenticate API call.
files body Array Required. List of files that are uploaded.
Curl
curl -X PUT -u 'Functional ID:Password' 'https://requesturl/ca/rest/content/v1/model/build'  -H 'apiKey: ZjMzYzg1ZDYtNTk1Nwhi5782NzItYjg3Mzg2ZGQwOGNhO3h5aWJtO2RlZmF1bHQ=' -H 'accept: application/json' -H 'Content-Type: multipart/form-data' -F 'file=@/path/test.pdf;type=application/pdf'
Java
import java.io.IOException;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.RequestBody;
import java.util.Base64;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import java.io.File;


public class testcode {
  public static void main(String[] args) {
  
    String encoding = Base64.getEncoder().encodeToString(("Functional ID:Password").getBytes());
    OkHttpClient client = new OkHttpClient();
    MediaType mediaType = MediaType.parse("multipart/form-data");
    
    RequestBody body =  new MultipartBody.Builder()
        .addFormDataPart("file", "test.pdf", RequestBody.create(mediaType, new File("/path/test.pdf")))
        .addFormDataPart("file", "test.pdf", RequestBody.create(mediaType, new File("/path/test.pdf")))
        .build();
    
    Request request = new Request.Builder()
      .url("https://requesturl/ca/rest/content/v1/model/build")
      .put(body)
      .addHeader("content-type", "multipart/form-data")
      .addHeader("apiKey", "ZjMzYzg1ZDYtNTk1Nwhi5782NzItYjg3Mzg2ZGQwOGNhO3h5aWJtO2RlZmF1bHQ=")
      .addHeader("Authorization", "Basic " + encoding)
      .build();


    try {
      Response response = client.newCall(request).execute();
      System.out.println(response.body().string());
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
}


/*
 * The JAR files in Referenced Libraries could be found in the Download section with the following link:
 * 1. okhttp.jar - https://github.com/square/okhttp
 * 2. okio.jar - https://github.com/square/okio
 */
JavaScript
let request = require("request");
let Base64 = require('js-base64').Base64;


let encoding = Base64.encode('Functional ID:Password');
let options = {
  method: 'PUT',
  url: 'https://requesturl/ca/rest/content/v1/model/build',
  headers:
  {
    'content-type': 'multipart/form-data;',
    'apiKey' : 'ZjMzYzg1ZDYtNTk1Nwhi5782NzItYjg3Mzg2ZGQwOGNhO3h5aWJtO2RlZmF1bHQ=',
    'authorization': "Basic " + encoding
  },
  formData:
  { file:
    [
        { value: fs.createReadStream("/path/test.pdf"),
          options: { filename: 'test.pdf' }
        }
    ]
  }
};


request(options, function (error, response, body) {
  console.log(body)
  if (error) throw new Error(error);
});
Python
import requests
import base64
encoding = base64.b64encode(b'Functional ID:Password')


files = [('file', open('/path/test.pdf', 'rb')), ('file', open('/path/test2.pdf', 'rb'))]


url = "https://requesturl/ca/rest/content/v1/model/build"
headers = {
 "apiKey" : "ZjMzYzg1ZDYtNTk1Nwhi5782NzItYjg3Mzg2ZGQwOGNhO3h5aWJtO2RlZmF1bHQ=",
 "authorization": "Basic " +  encoding.decode("utf-8") 
}


response = requests.request("PUT", url, files = files, headers=headers)