Mock Servers -- Request Body Matching not working

I have a mock server set up with two examples (w/ fake Personal Info attributes):

Example1 has its expected request body saved as:

{
            "FraudPointRequest": {
                "Options": {
                    "IncludeRiskIndices": 1,
                    "IncludeModels": {
                        "FraudPointModel": "FP31505_0"
                    },
                    "AttributesVersionRequest": "FraudPointAttrv202"
                },
                "SearchBy": {
                    "SSN": "083949521",
                    "Address": {
                        "StreetAddress1": "1013 Weda Cir",
                        "Zip5": "94404"
                    },
                    "IPAddress": "75.190.227.166",
                    "Phone10": "1000000002",
                    "Name": {
                        "First": "MFKR1_APPROVE",
                        "Last": "Artel"
                    },
                    "DOB": {
                        "Year": 1991,
                        "Day": 29,
                        "Month": 10
                    }
                },
                "User": {
                    "DLPurpose": "3",
                    "GLBPurpose": "5",
                    "QueryId": "MFKR1_APPROVE"
                }
            }
        }

Example2 has its expected request body as:

{
            "FraudPointRequest": {
                "Options": {
                    "IncludeRiskIndices": 1,
                    "IncludeModels": {
                        "FraudPointModel": "FP31505_0"
                    },
                    "AttributesVersionRequest": "FraudPointAttrv202"
                },
                "SearchBy": {
                    "SSN": "083949521",
                    "Address": {
                        "StreetAddress1": "1013 Weda Cir",
                        "Zip5": "94404"
                    },
                    "IPAddress": "75.190.227.166",
                    "Phone10": "1100000009",
                    "Name": {
                        "First": "MFKR1_DENY",
                        "Last": "Artel"
                    },
                    "DOB": {
                        "Year": 1991,
                        "Day": 29,
                        "Month": 10
                    }
                },
                "User": {
                    "DLPurpose": "3",
                    "GLBPurpose": "5",
                    "QueryId": "MFKR1_DENY"
                }
            }
        }

I sent a POST request to the set-up Mock Server endpoint with the following request:

{
            "FraudPointRequest": {
                "Options": {
                    "AttributesVersionRequest": "FraudPointAttrv202",
                    "IncludeModels": {
                        "FraudPointModel": "FP31505_0"
                    },
                    "IncludeRiskIndices": 1
                },
                "User": {
                    "GLBPurpose": "5",
                    "DLPurpose": "3",
                    "QueryId": "MFKR1_DENY"
                },
                "SearchBy": {
                    "Address": {
                        "StreetAddress1": "1013 Weda Cir",
                        "Zip5": "94404"
                    },
                    "IPAddress": "75.190.227.166",
                    "Phone10": "1100000009",
                    "DOB": {
                        "Year": 1991,
                        "Day": 29,
                        "Month": 10
                    },
                    "Name": {
                        "First": "MFKR1_DENY",
                        "Last": "Artel"
                    },
                    "SSN": "083949521"
                }
            }
        }

Why does this match to the “approve” case (example1) rather than the deny (example2) one when only the latter case matches the request bodies? Can anyone please test and see if you can reproduce this?

Resolved. Turns out I was missing the “Content-Type: application/json” header from these examples.

For anyone else out there.

The body matching on the mocks is fairly straight forward and will always return example 1 if it can’t get a good match on the body. (As long as the operation and path are the same).

As you’ve found out, the headers are also important for matching purposes. (These are looked at before the body in the matching algorithm)

2 Likes