How to quickly fake any kind of API response for test

If you find yourself in a situation where you want to test a specific JSON-response from an API endpoint, but either you can’t get the response you need from your real endpoint or maybe your real endpoint is not ready yet, this is pretty useful.

  1. Just go to https://designer.mocky.io/
  2. Press new mock button.
  3. Design what kind of response you want to get with various other settings:

    I have put this response for a forum question for example: [ { "optionname": "optiona" }, { "optionname": "optionb" } ] This should return a json array with optionname as the key.
  4. Press generate .... button to get the URL:
    image
  5. You can test the URL in a browser to check if it really returns whatever you want:
    image
  6. Add the URL to your API connector as usual:
  7. Initialize as usual:
  8. Use it wherever you want:
    image
    image
9 Likes

Is there an easy way to convert this mock API call into the real API call once it is ready? Basically, if we use this approach to use Mock data and setup workflows or elements that use the API response, is there a way to simply modify the mock API endpoint to become the real endpoint without needing to update all workflows or elements that used the mock endpoint data values?

I believe it will be as simple as updating the api connector’s corresponding call’s URL and settings from the mock to the real one. If you modeled it as close to the real one as possible, it shouldnt be a problem.

1 Like

Thanks @hergin. I wasn’t familiar wth Mocky! Will definitely check it out.

couldn’t you do that by creating a public backend workflow with a custom text response and call that backend workflow from the api connector easily without any third party service?

Try and report back and let’s have another alternative way of doing it. I am sure there are more ways :+1:

1 Like