smocker icon indicating copy to clipboard operation
smocker copied to clipboard

application/x-www-form-urlencoded body matcher

Open mknapik opened this issue 2 years ago • 1 comments

I have a use case for mocking third-party API where data is sent with POST via body in application/x-www-form-urlencoded format. It seems Smocker is pretty flexible in terms of various matchers for individual JSON keys but matchers for urlencoded params is not supported.

So far my workaround looked the following:

- request:
    method: POST
    path: "/test"
    headers:
      Content-Type: application/x-www-form-urlencoded
    body:
      matcher: ShouldEqual
      value: username=${username}&password=${password}
  response:
    status: 200
    headers:
      Content-Type: application/json
    body: >
      {
      }

However, this solutions relies on order of the params which should not be relevant.

Would you consider adding support for urlencoded body matching?

mknapik avatar Mar 07 '22 13:03 mknapik

Yep, that should be a supported feature.

We'll try to implement this asap :)

Thiht avatar Mar 07 '22 13:03 Thiht

Hi! Is there maybe any news here?

Powerrr avatar May 22 '23 12:05 Powerrr

Added in 0.18.4

gwleclerc avatar Oct 04 '23 19:10 gwleclerc