Submitting a document for processing

Submit a file for metadata, content analysis and structure extraction or for a PDF rendition.

Syntax: POST /ca/rest/content/v1/content Analyzer.

Table 1. Submitting document requirements
Property Data Type Description
apiKey
header (required)
String To authenticate API call.
content-type
header (required)
multipart/form-data Information that should appear in the final JSON, this is required to be a list separated by a comma.
file
body (required)
File The file to be processed, the only accepted formats are (PDF, JPG, JPEG, TIF, TIFF, PNG, DOC, DOCX).
responseType
body (required)
String All the possible output options, the only accepted formats are (JSON, PDF, UTF8).
jsonOptions
body (required if JSON was selected as part of the users output)
String Information that should appear in the final JSON, this is required to be a list separated by a comma.
uniqueId
body (optional)
String Customer unique id to be included in final output..
Note: 1. This design takes into consideration the document size and system activity which can have a response time longer than the standard API request timeout, hence Business Automation Content Analyzer provides a near real-time response only. The maximum file size which is accepted is 250MB.
Note: 2. For the file with Unicode characters in the file name, ensure the code used to call the API should handle Unicode characters or it gets error code CIWCA16001.

POST/contentAnalyzer

cURL: Example request
 curl -X POST -u 'Functional ID:Password' 'https://requesturl/ca/rest/content/v1/contentAnalyzer' -H 'accept: application/json' -H 'apiKey: e576619f-fa35-42a8-abf3-f035fb43af19' -H 'Content-Type: multipart/form-data' -F 'file=@car.pdf;type=application/pdf' -F 'responseType="json","pdf","utf8"' -F 'jsonOptions="ocr","dc","kvp"'

# The syntax may varies between operating systems or versions. For example, 'responseType="\"json\",\"pdf\",\"utf8\""' should be used instead of 'responseType="json","pdf","utf8"' for some environments.
Python: Example request
import requests
import base64
encoding = base64.b64encode(b'Functional ID:Password')
url = "https://requesturl/ca/rest/content/v1/contentAnalyzer"

files = {'file': ('test.pdf', open('/path/test.pdf', 'rb'), "multipart/form-data")}
data = {
'responseType' : ""utf8","json","pdf"",
'jsonOptions' : ""ocr","dc","kvp""
}
headers = {
"apiKey" : "d7239f16-98f0-4024-9688-604750a98abb",
"authorization": "Basic " + str(encoding)
}

response = requests.request("POST", url, files = files, data=data, headers=headers)
print(response.text)
JavaScript: Example request
var fs = require("fs");
var request = require("request");
var Base64 = require('js-base64').Base64;

var encoding = Base64.encode('Functional ID:Password');
var options = {
  method: 'POST',
  url: 'https://requesturl/backendsp1/ca/rest/content/v1/contentAnalyzer',
  headers:
  {
    'content-type': 'multipart/form-data;',
    'apiKey' : 'd7239f16-98f0-4024-9688-604750a98abb',
    'authorization': 'Basic ' + encoding
  },
  formData:
  { file:
    { value: fs.createReadStream("/path/to/pdf/file"),
    options: { filename: 'TLG6TV.pdf', contentType: null }
    },
    responseType: "\"json\", \"pdf\", \"utf8\"",
    jsonOptions: "\"ocr\",\"dc\",\"kvp\""
  }
};

request(options, function (error, response, body) {
  if (error) throw new Error(error);
});
Java: Example request
import java.io.IOException;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.RequestBody;
import okhttp3.MultipartBody;
import java.util.Base64;
import okhttp3.MediaType;
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("responseType", "\"utf8\",\"json\",\"pdf\"")
        .addFormDataPart("jsonOptions", "\"ocr\",\"dc\",\"kvp\"")
        .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/contentAnalyzer")
  .post(body)
  .addHeader("content-type", "multipart/form-data")
  .addHeader("apiKey", "d7239f16-98f0-4024-9688-604750a98abb")
  .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:
        okhttp.jar - https://github.com/square/okhttp
        okio.jar - https://github.com/square/okio
        */
Example response
{
  "status": {
    "code": 202,
    "messageId": "CIWCA12001",
    "message": "Content Analyzer request was created"
  },
  "data": {
    "message": "json,pdf,utf8 processing request was created successful",
    "fileNameIn": "car.pdf",
    "analyzerId": "fe76c510-e2d8-11e8-9ee8-81a7944aa061",
    "type": [
      "json",
      "pdf",
      "utf8"
    ]
  }
}