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 payload
{ 
    "request": { 
    "ID": "12345", 
    "type": "account" 
    }
}
response payload
{
    "response": {
    "firstName": "John",
    "lastName": "Doe",
    "account": {
        "id": "12345",
        "type": "billing"
    }
   }
}

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

request payload
<?xml version="1.0" encoding="UTF-8"?>
    <root>
        <userId>123</userId>
        <type>User</type>
    </root>
response payload
<?xml version="1.0" encoding="UTF-8"?>
    <root>
        <empId>123</empId>
        <city>San Jose</city>
        <firstName>John</firstName>
        <lastName>Doe</lastName>
        <state>CA</state>
    </root>
Please note that a XML/SOAP data with 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

request payload
<?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>
response payload
<?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/quotation">
      <m:GetQuotationResponse>
         <m:Quotation>Here is the quotation</m:Quotation>
         <m:ID>1000</m:ID>
      </m:GetQuotationResponse>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Table of Contents