Hi!
I am trying to create a custom response based on the request body. That means, if I send a Json element in the body, for example
AccommodationOffersRQ.OfferFilters.AccomFilter
how can I specify the EXPECTATION, so it is triggerred?
So far I always get just the default response.
What should I put?
BODY then in name AccommodationOffersRQ.OfferFilters.AccomFilter? and then Comparison Exist?
please advice
You can use the Advanced Mock feature to achieve this with body parameter matching. Details are available in our documentation: Mock expectations - Apidog Docs
will do the trick, but it is not responding with this response, but only with the default
does not help
I think it does not support using the period “.” to represent multiple levels of matching.
so how can I address it?
Try utilizing the include/not-include match rule.
I think now it is working.
thank you
can I speify in the response that the value of HotelID should be:
“HotelRef”: {
“HotelID”: {{AccommodationOffersRQ.OfferFilters.AccomFilter.AccomSelectors.HotelIffCodes}}
},
being from the request body?
or I have to do it in the custom script?
does the Mock Script then apply to all the mock responses? (with expectation and without?)
so a script like:
var requestJsonData = $$.mockRequest.body.toJSON();
var responseJson = $$.mockResponse.json();
responseJson.AccommodationOffersRS.Offers.OfferServices.Accommodation.HotelRef.HotelID = requestJsonData.AccommodationOffersRQ.OfferFilters.AccomFilter.AccomSelectors.HotelIffCodes;
$$.mockResponse.setBody(responseJson);
should set it correctly. but it does not do anything so far…
To utilize advanced matching capabilities, leverage the Mock Custom Scripts feature. Please note that mock script priority is lower than mock expectation priority. The mock service will prioritize returning the mock expectation if the request matches its defined conditions.