HTTP Scripts with JSON Requests
HTTP scripts with requests/messages containing POST bodies in JSON format (Content-type header/mime type application/json
) are special for EEM since the characters { and } are used to reference variables. JSON messages typically contain several occasions of { and }, which are then by default considered as references to variables.
This page shows several approaches to cope with this.
Introduce dummy variables with same value
For simple cases it is sufficient to use dummy variables that contain the same name as value.
Example:
The POST body contains a parameter value abc{def}xyz
. {def
} is considered as reference to a variable which does not exist. This triggers an error during replay.
Solution: Define a variable in the script configuration (section Variables):
name: def
value: {def
}
Convert POST parameters to POST file.
EEM has different approaches to configure the POST body for a message.
Parameters
This is the default handling. The POST body of the recording is split into parameters, & is considered as separator.
Parts
Request bodies with mime type multipart/form-data
are parsed into parts. Individual parts may be files.
POST file
Request bodies with mime type text/xml
are not parsed in any way. Variables can still be used here, but if a variable reference cannot be resolved this is ignored.
This POST file approach is recommended for JSON scripts as well. To use it, copy the POST body from the recording of the corresponding message (tab Stream of http content) to the tab Post File (Message Properties, General). Delete the existing entries in tab Parameters for the message.
The EEM Editor will automatically handle POST requests with content type application/json
via the POST file approach starting with release 7.1 SP11.
Use different separators for variable references
This feature is available starting with Solution Manager release 7.1 SP10.
left.variable.boundary
right.variable.boundary