Question
Assume that parameters are specified in a HTTP request body in JSON format.
Is it possible to get the parameters when HULFT Square receives the request and use them in a script specified in an API project?
Answer
Yes, it is possible. You can use script variables in an API project to pass parameters in an HTTP request to a script to execute.
-API Project Settings
In [Request settings], set [Request body] to "JSON" and specify script variables of the script specified in the API project.
With these settings, the parameters will be passed to the script variables in the specified script.
-HTTP request on the external service side
You need to specify the parameter names registered in the [Request settings] in the API project.
The following is an example of a JSON statement.
"RequestBody": {
"param": "test"
}
-Script specified in the API project
The value stored in the script variable is a string including element names in the form of an XML tag, so you need to extract the elements from the target tags using [Mapping].
Specifically, please extract the elements between "<param></param>".
The logic used for the extraction might be a combination of [Left String] logic, [Right String] logic, and so on.
There are multiple extraction methods, so please refer to the manual below and use the logics that suit your situation.
[Mapper Logic Guide]>[String]
https://www.hulft.com/help/en-us/HULFTSquare/Content/Designer/Mapper/mpp_string_menu.htm
Comments
0 comments
Article is closed for comments.