Map
The Mockgee MAP step empowers you to dynamically transfer the contents of the request payload into the response payload during runtime.
For instance, if you wish to include the phoneNumber from the request payload in the API mock response, this feature provides a seamless solution for achieving such dynamic payload mapping.
JSON
For example to return ID
value in the mock response data. Configure below request and response JSONPath
.
Request JSONPath - request.ID
Response JSONPath - response.account.id
{
"request": {
"ID": "12345",
"type": "account"
}
}
XML
For example to return userId
value in the mock response data. Configure below request and response XPath
.
Request XPath - root.userId
Response XPath - root.empId
<?xml version="1.0" encoding="UTF-8"?>
<root>
<userId>123</userId>
<type>User</type>
</root>
namespace
must be included in XPath.Example of mapping QuotationsName
field of request SOAP to QuotationsName
field of response data using XPath.
Request Path - m:GetQuotation.m:id
Response Path - m:GetQuotationResponse.m:ID
<?xml version = "1.0"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV = "http://www.w3.org/2001/12/soap-envelope"
SOAP-ENV:encodingStyle = "http://www.w3.org/2001/12/soap-encoding">
<SOAP-ENV:Body xmlns:m = "http://www.xyz.org/quotations">
<m:GetQuotation>
<m:id>1000</m:id>
<m:QuotationsName>MiscroSoft</m:QuotationsName>
</m:GetQuotation>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>