Post Task Variable (Binary)

Sets the serialized value for a binary variable or the binary value for a file variable visible from the task. A variable is visible from the task if it is a local task variable or declared in a parent scope of the task. See documentation on visiblity of variables.

Method

POST /task/{id}/variables/{varName}/data

Parameters

Path Parameters

Name Description
id The id of the task to set the variable for.
varName The name of the variable to set.

Request Body

For binary variables a multipart form submit with the following parts:

Form Part Name Content Type Description
data application/octet-stream

The binary data to be set.

For File variables, this multipart can contain the filename, binary value and MIME type of the file variable to be set. Only the filename is mandatory.

valueType text/plain The name of the variable type. Either Bytes for a byte array variable or File for a file variable.
data application/json Deprecated: This only works if the REST API is aware of the involved Java classes.

A JSON representation of a serialized Java Object. Form part type (see below) must be provided.

type text/plain Deprecated: This only works if the REST API is aware of the involved Java classes.

The canonical java type name of the variable to be set. Example: foo.bar.Customer. If this part is provided, data must be a JSON object which can be converted into an instance of the provided class. The content type of the data part must be application/json in that case (see above).

Result

This method returns no content.

Response Codes

Code Media type Description
204 Request successful.
400 application/json The variable value or type is invalid, for example if no filename is set. See the Introduction for the error response format.
500 application/json Variable name is null. Task id is null or does not exist. See the Introduction for the error response format.

Example

Request

(1) Post binary content of a byte array variable:

POST /task/aTaskId/variables/aVarName/data

------------------------------354ddb6baeff
Content-Disposition: form-data; name="data"; filename="image.png"
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary

<<Byte Stream ommitted>>
------------------------------354ddb6baeff
Content-Disposition: form-data; name="valueType"
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 8bit

Bytes
------------------------------1e838f8f632a--

(2) Post the JSON serialization of a Java Class (deprecated):

POST /task/aTaskId/variables/aVarName/data

------------------------------1e838f8f632a
Content-Disposition: form-data; name="type"
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 8bit

java.util.ArrayList<java.lang.Object>
------------------------------1e838f8f632a
Content-Disposition: form-data; name="data"
Content-Type: application/json; charset=US-ASCII
Content-Transfer-Encoding: 8bit

["foo","bar"]
------------------------------1e838f8f632a--

(3) Post a text file:

POST /task/aTaskId/variables/aVarName/data

Request Body:

---OSQH1f8lzs83iXFHphqfIuitaQfNKFY74Y
Content-Disposition: form-data; name="data"; filename="myFile.txt"
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: binary

<<Byte Stream ommitted>>
---OSQH1f8lzs83iXFHphqfIuitaQfNKFY74Y
Content-Disposition: form-data; name="valueType"
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 8bit

File
------------------------------1e838f8f632a--

Response

Status 204. No content.

目录: