Request.json dynamic query

Hello guys, I’m making the following request:

  "fileterContacts": {
    "schema": {
      "method": "GET",
      "host": "<%= iparam.domainName %>.freshdesk.com",
      "path": "/api/v2/contacts",
      "headers": {
        "Authorization": "Basic <%= encode(iparam.apiKey) %>",
        "Content-Type": "application/json"
      },
      "query": {
        "email": "<%= context.email %>",
        "mobile": "<%= context.phone %>"
      }
    }
  },

But my query is dynamic, I can pass only email or just phone, or both together, in this example it filters by passing phone as empty if I do not pass anything, which compromises the query, so I need to somehow solve this problem, example if the parameter is null or something like it should not be sent!

I don’t think it’s a good solution to create 3 requests that do the same thing just because of parameters of a query

I had a similar requirement.

I’m glad I’m not alone. I don’t see any reason why query params need to be part of the template in the first place. It does not pose a security threat in any way. It only makes the request template unnecessarily rigid.

The way I worked around it was to construct the query params as part of the path itself.

"path": "/api/v2/contacts?email=xxx&mobile=yyy",
1 Like