Overview

This API makes it possible to carry out mass file uploads.
The process is based on jobs and import items attached to these jobs.
An element to be imported consists of a binary and qualification data: the item is a temporary object, which does not exist in the database, but whose simulated view can be obtained at any time.
A job is attached to a user. The process consists in attaching items to be imported to this job, qualifying them, then launching the actual creation of the final objects.
Item qualifications and object creations are asynchronous (asynchronous job works).

An item corresponds to any type of asset. A qualifying property of the same name in two different asset types must absolutely be of the same type (and nature if applicable).

End points

standard URI

All standard endpoints for massimport starts with /api/rest/massimport.

standard generic URI

End points that start with /api/rest/massimport/data have the same characteristics as standard end points of the type /api/rest/{dam/}data.

catalog

GET /api/rest/massimport or GET /api/rest/massimport/data (or GET /api/rest/massimport/catalog)

To get headers, use parameter headers:

GET /api/rest/massimport?headers=true

Jobs end points

Get headers

GET /api/rest/massimport/job/headers

Get job data

GET /api/rest/massimport/job/{jobid}

Parameters:

Get job list

GET /api/rest/massimport/job for infinite list

GET /api/rest/massimport/job/list for paginated list

Parameters:

Any standard parameters of list or search query, plus specific parameters (see Get job data)

Get job item list

GET /api/rest/massimport/job/{jobid}/item for infinite list

GET /api/rest/massimport/job/{jobid}/item/list for paginated list

note

you can use item or items

you can use item or items

Parameters:

Any standard parameters of list or search query, plus specific parameters (see Get job data)

Show workflow of job

GET /api/rest/massimport/job/workflow

Show new possible workflow action

GET /api/rest/massimport/job/{jobid}/workflow

old way continue to work:

GET api/rest/massimport/job/{jobid}?workflows=true&withData=false

Create a new job

POST /api/rest/massimport/job

The jobowner is automatically set to surfer that invoke the end point.

Create a new job with data (multipart/form-data)

Provide a json in a field named json (or in a field with your wanted name, and a parameter named jsonproperty to set this name, in form or in query).

By example, set the job name and the job owner (id=11):

curl --request POST 
  --url https://<host>/api/rest/massimport/job \
  --header 'authorization: xxxx' 
  --header 'content-type: multipart/form-data; boundary=---011000010111000001101001' 
  form 'json={"name": "test","jobowner": 11}'

Create a new job and attach items

You can attach items to the new job with field named itemIds:

To specify queries to select assets, user the prefix itemIds_ followed by the name of the asset resource (example: itemIds_asset={“owner”:”123”}

Example, with list of items (here ids 1 and 2):

curl --request POST \
  --url https://<host>/api/rest/massimport/job \
  --header 'authorization: xxxx' \
  --header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \
  --form 'json={
   "name": "test",
   "itemIds": [1,2]
}'

Example with query (here, all items created on june, the 3rd, 2020):

curl --request POST \
  --url https://<host>/api/rest/massimport/job \
  --header 'authorization: xxxx' \
  --header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \
  --form 'json={
   "name": "test",
   "itemIds": { "created": {"eq": "20200603"} }
}'
note

In creation, this is a simplification of the general syntax (see Add or remove items (asynchronous)).

In creation, this is a simplification of the general syntax (see Add or remove items (asynchronous)).

The parameter itemIds can be set outside the json as independent field

Example with independent field:

curl --request POST \
  --url https://<host>/api/rest/massimport/job \
  --header 'authorization: xxxx' \
  --header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \
  --form 'json={"name": "test"}' \
  --form 'itemIds=["1",2]'

Use true or $auto for itemIds to attach all not currently attached items

Parameter withItems can be used to export item data within creation result data (of job). Parameter props can filter item properties, by prefixing them with “$item.” (example: props=id,name,$items.id,$items.name)

Parameters can be set in query:

Delete job

DELETE /api/rest/massimport/job/{id}

parameters:

Items end points

Headers

GET /api/rest/massimport/item/headers

Create a new item (binary in body)

Use POST /api/rest/massimport/item, with binary file in body

The filename (this name is the store final filename and will be use to determinate mimetype if the file) must be provided

The content-type must be provided by content-type header, and can be anything but application/json. Do not use application/json, because this content-type is reserved for metadata : to upload a binary json file, use any other content type (i.e. application/octet-stream). The final mimetype of the file will be determinated from the filename extension.

Example (curl):

curl --request POST \
  --url https://<host>/api/rest/massimport/item \
  --header 'authorization: xxxx' \
  --header 'content-disposition: attachment; filename="filename.jpg"' \
  --header 'content-type: image/jpeg' \ 
  --data '@myfile.jpg'

Create a new item (multipart/form-data)

Use POST /api/rest/massimport/item, with content-type multipart-formdata

The binary file must be provided in the field named binary. A filename, other than the field content-disposition, can be provided with the query parameter named prop_binary or multipart/form-data field binary : this filename will be the final filename.

Example (curl, with filename in multipart/form-data):

curl --request POST \
  --url https://<host>/api/rest/massimport/item \
  --header 'authorization: xxxx' \
  --header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \
  --form binary=@myfile.jpg \
  --form binary=filename.jpg

In this mode you can specify data for the item in a json. See the

Example setting target job and name (curl):

curl --request POST \
  --url https://<host>/api/rest/massimport/item \
  --header 'authorization: xxxx' \
  --header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \
  --form binary=@myfile.jpg \
  --form json={"name":"example","job":42}

Create a new item from an asset

Made as if to create an item from scratch, and on top of that, use asset parameter (or $asset) to specify the source asset as:

The parameter can be included in the json.

Example (curl), with json in body, targetting job 2:

curl --request POST \
  --url https://<host>/api/rest/massimport/item \
  --header 'authorization: xxxx' \
  --header 'content-type: application/json' \ 
  --data '{
  "job": "2",
  "asset": "asset_3173"
}'

Add or remove items (asynchronous)

The parameter itemIds used in a job modification request allows to add items to the job or remove items from the job (detach them make them without any job). This parameter can be used as separated parameters (in multipart/form-data field, in query parameter…) or inside the json data description sent to modify properties of the job.

the json contains one or both of the following properties:

Example to add items:

{
   "add":[1,2,"3"]
}

Example to add all items created on june, the 3rd 2020:

{
   "add": {
       "created": "20200603"
   }
}

When creating a job, as you can only add items, you can simplify the json by indicating only the value of the add property.

Example to create a job with name “test” with all data in the json description:

url --request POST \
  --url https://<host>/api/rest/massimport/job \
  --header 'authorization: xxxx' \
  --header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \
  --form 'json={
   "name": "test",
   "itemIds": { "add": ["1",2] }
}'

Same example with simplified syntax:

url --request POST \
  --url http://<host>/api/rest/massimport/job \
  --header 'authorization: xxxx' \
  --header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \
  --form 'json={
   "name": "test",
   "itemIds": ["1",2]
}'

Same example with itemIds in its own field:

curl --request POST \
  --url https://<host>/api/rest/massimport/job \
  --header 'authorization: xxxx' \
  --header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \
  --form 'json={
   "name": "test"
  }' \
  --form 'itemIds={ "add": ["1",2] }'

You can also use query parameters, one to add with name add_itemIds, one to remove with the name remove_itemIds, for ids

Example:

curl --request POST \
  --url 'https://<host>/api/rest/massimport/job?add_itemIds=1&add_itemIds=2' \
  --header 'authorization: xxxx' \
  --header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \
  --form 'json={
   "name": "test"
}'

You can also use query parameters, one to add with name add_itemIds_query, one to remove with the name remove_itemIds_query, for query

Example:

curl --request POST \
  --url 'https://<host>/api/rest/massimport/job?add_itemIds_query=%7B%20%22created%22%3A%20%7B%22eq%22%3A%20%2220200603%22%7D%20%7D' \
  --header 'authorization: xxxx' \
  --header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \
  --form 'json={
   "name": "test"
}'

The ways are combinable, but if there is a parameter in the multipart/form-data, its query equivalent is ignored.

The request invocation ends immediately and the modifications are scheduled to be done asynchronously. Until the demands are not finished, the job is marked outstanding (you can get this state in the status section of a job data).

Add or remove items (asynchronous)

Do a request on an item to modify the property job (or set it when creating the item).

Example:

curl --request PUT \
  --url https://<host>/api/rest/massimport/data/item/18 \
  --header 'authorization: xxxx' \
  --header 'content-type: application/json' \
  --data '{
	"job": 12
}'

Qualify items (asynchronous)

You can schedule items qualification on a job, with the parameter metadata. This parameter works like itemIds parameter (you can put in json, in a multipart/form-data field, in a query parameter).

The value is a json with :

Example:

curl --request PUT \
  --url https://<host>/api/rest/massimport/job/2 \
  --header 'authorization: xxxx' \
  --header 'content-type: application/json' \
  --data '{
	"metadata": {
		"ids": [1,2],
		"type":"asset"
	}
}'

Example:

curl --request PUT \
  --url https://<host>/api/rest/massimport/job/2 \
  --header 'authorization: xxxx' \
  --header 'content-type: application/json' \
  --data '{
	"metadata": {
		"ids": [1,2],
		"type":"asset",
		"data": {
		    "name":"xxxx"
		    "keywords": {
		          "$mode": "appendnew",
		          "$values": [3342,2231]
		    }
		},
		"workflow":"publish"
	}
}'

Qualify item (synchronous)

To qualify an item, modify it with the parameter metadata, the same as when qualifying items asynchronously (by job), but without ids.

The syntax is the same as standard modification. If you use a json, if a property metadata exists in the resource item, use $metadata.

Configuration (API)

A minimal configuration is automatically generated for the both job and item structures. Use the tag REST_API_MASS_IMPORT_INCLUDE to export a field which is not automatically selected. Use the dam/data tags to configure features (see Tags )

Job

All the features are allowed by default:

Jobs are secured by default.

Fields exported by default:

Item

All the features are allowed by default:

Jobs are secured by default.

Fields exported by default:

Configuration (plug-in)

Extensions (business services)

The class com.noheto.restapi.MassImport from jar restapibs.jar (copy it from plug-in WXM-RESTAPI) provides an API you can use in you own plug-in, to retrieve information about the items to be imported.

Get item target type in your extensions

String MassImport.getDataType(String/id|IObjectReadonly)

Get simulation data in your extensions

com.google.gson.JsonObject MassImport.getItemSimu({wsnoheto.engine.CTSurfer,}{org.apache.log4j.Logger,}String/id|IObjectReadonly,boolean/resetCache)

org.json.JSONObject MassImport.getItemSimuJson({wsnoheto.engine.CTSurfer,}{org.apache.log4j.Logger,}String/id|IObjectReadonly,boolean/resetCache)

Structures

Bases

Code

Type

Nature

Default

List

View

Edit

Mandatory

Null if empty

Indexed

Tags

id

identity

(tick)

created

datetime

(tick)

modified

datetime

(tick)

owner

(tick)

parent

sentence

child

word

status

child

wkfmassimportjob

name

word

(tick)

(tick)

(tick)

activated

child

activated

1

changes

text

[]

jobowner

child

user

(tick)

(tick)

(tick)

(tick)

(tick)

expecteditems

integer

0

defaultcollection

word

(tick)

(tick)

(tick)

outstanding

child

activated

2

(tick)

(tick)

(tick)

(tick)

(tick)

previousowner

child

user

(tick)

(tick)

(tick)

activestep

word

(tick)

(tick)

(tick)

primaryjob

child

massimportjob

(tick)

(tick)

(tick)

jobprogress

text

Code

Type

Nature

Default

List

View

Edit

Mandatory

Null if empty

Indexed

Tags

id

identity

(tick)

created

datetime

(tick)

modified

datetime

(tick)

owner

(tick)

parent

sentence

child

word

status

child

wkfmassimportjob

name

word

(tick)

(tick)

(tick)

activated

child

activated

1

changes

text

[]

job

child

massimportjob

(tick)

(tick)

(tick)

binary

file

(tick)

(tick)

objectid

word

(tick)

(tick)

(tick)

objecttype

word

(tick)

(tick)

(tick)

changescache

text

rejectreason

text

datachanges(i18n)

text

(tick)


itemisvalid

child

activated

2

(tick)

(tick)


itemhaswarnings

child

activated

2

(tick)

(tick)

Workflows

draft

pending

done

paused

cancelled

start (blue star)

pause (blue star)

(blue star) restart

cancel (blue star)

cancel (blue star)

finish (blue star)

failed

rejected

draft

duplicate

index

approved

processing

imported

markduplicate (blue star)

index (blue star)

(blue star) reject

validatebinary (blue star)

(blue star) invalidatebinary

index (blue star)

(blue star) reject

complete (blue star)

(blue star) reject

approve (blue star)

import (blue star)

(blue star) fail

(blue star) index

approve (blue star)

Fulltext indexation of simulation data

To allow fulltext search within items, item structure must have i18n datachanges field, as well as the associated fields for each desired locale, and these fields must be indexed.

Check the structures

You can check if structures or workflows are valid in the plug-in status page.

Job handling

Create a job

Get job data

Follow a job (workflow and outstanding state)

Control job (workflow)

Primary or secondary job

Delete a job

Job progress

Item handling

Get item data

Get final object simulation

Upload binary (A single media)

Upload archives (Several media at once)

Simulation

Reject reason

Asynchronous operations