1

I am working with mountebank to create mocks for an External REST API which is a POST request with content-type : application/x-www-form-urlencoded.

The API is of format

https://<url>/dpay/MPmt

and data payload is passed in format msg=01223~20170607114321~ABC~12345~NA~NA

I have to search on the basis of ~ABC~12345~ which would remain constant.

I have used contains, matches and equals predicates but was not able to run them while passing the payload in request body.

However, I was able to get it running when passing payload as a query parameter

https://url/dpay/MPmt?msg=01223~20170607114321~ABC~12345~NA~NA

but can't find a way to get it done when passed in request body.

Any pointers would be really appreciated.

amarnath
  • 785
  • 3
  • 19
  • 23
nikki
  • 13
  • 5

1 Answers1

2

Use the predicate "contains" and pass your matching string only. What I suspect is that you are using

"contains" : { "body" : { "msg": "~ABC~12345~" } }

this will look for an msg variable in the request body, instead, use

"contains" : {"body": "~ABC~12345~"}

and it will match it directly in your request body.

I faced the same issue, Hope it works for you.

Ankit
  • 46
  • 3