Talend Cloud API Tester allows you to manipulate data via functions.
Functions can create new data or transform existing data. The functions that transform data apply on the value of the expression they finish.
Usage examples
If you want to retrieve the first 10 planet names in the
list of planets in your Star Wars API, you can use the expression: ${"Star-wars API"."Get 10 planet
names"."response"."body".jsonPath("$.results[:10].name")}
. The method jsonPath
parses the result of the expression ${"Star-wars API"."Get 10 planet names"."response"."body"}
.
If you want to retrieve logs from the past week, you can create a URL with
expressions in the query parameters: https://myapi.com/logs?from=${timestamp().addTime("WEEK",
"-1")}&to=${timestamp()}
.
If you want to generate the
current date in ISO format, you can use the expression ${timestamp().formatDate('TIMESTAMP', 'ISO_8601')}
.
Constants
When writing an expression like ${"toto"}
, the expression is evaluated as:
- The value of the current environment's variable
toto
if there is one. - The request/scenario/service/project
toto
that is at root-level in your repository if no environment variable matched. - The string
toto
in any other case.
Data creation
Function | Description | Arguments | Example |
---|---|---|---|
timestamp
|
Returns the number of milliseconds from January 1, 1970, 00:00:00 GMT to the date when it is evaluated. |
none |
Expression: Possible result: |
uuid
|
Returns a UUID. |
none |
Expression: Possible result: |
random
|
Returns a random number in range 0 <=
number < max . |
Maximum: defaults to 1000000000 |
Expression: Possible result: |
randomString
|
Returns a random string with a specific length. Note: This function is not reliable for password generation and should not be
used for this purpose.
|
Length: number of characters in the string. Defaults to 10. [a-z]: select this check box to include lowercase letters in the string. [A-Z]: select this check box to include uppercase letters. [0-9]: select this check box to include numbers. |
Expression: Possible result: |
Data transformation
Function | Description | Arguments | Example |
---|---|---|---|
base64
|
Encodes in base 64. |
none |
Expression: Result: |
lower
|
Converts all the characters to lower case using the rules of the default locale. |
none |
Expression: Result: |
length
|
Computes the length of its input:
|
none |
Expression: Result:
Expression: Result: Result: Expression: Result: |
substring
|
Returns a truncated input. |
Start: position of the first character that should be extracted (0 by default). End: position of the first character that should be omitted (end of the input by default). Note: The index of the first character is 0.
|
Expression: Result: Expression: Result: Expression: |
jsonPath
|
Returns the element(s) extracted from the JSON input with the
given JSON path selector . |
Selector: The JSON path selector that points to the part of the JSON to extract from the input. |
Expression: Result: |
xPath
|
Returns the element(s) extracted from the XML input with the
given XPath selector . |
Selector: The XPath selector that points to the part of the XML to extract from the input. |
Expression: Result: |
hmac
|
Creates a Hash-based Message Authentication Code . |
Cipher: the hash function ( : the secret key.
Output: the output type ( |
Expression: Result: Expression: Result: |
sha
|
Hashes its input. |
Cipher: the hash function
(
Output: the output type
( |
Expression: Result: Expression: Result: |
md5
|
Calculates the MD5 hash of its input. |
none |
Expression: Result: |
upper
|
Converts all the characters to upper case using the rules of the default locale. |
none |
Expression: Result: |
string
|
Quotes its input. |
Quotes: the character that
should be used to quote the input. ( |
Expression: Result: Expression: Result: Expression: Result: |
math
|
Performs the selected operation on the input value. |
Operation: Value: number |
Expression: Result: Expression: Result: Expression: Result: |
addTime
|
Adds or removes a number of the selected time unit from a date. |
Time unit: Value: integer (you can use a negative number to remove a time unit) |
Expression: Possible result: Expression: Possible result: |
formatDate
|
Converts a date into the selected format. |
Input format:
Output format: |
Expression: Possible result: Expression: Result: |