Lookup behaviour, method regex and a query parameter value

22 views
Skip to first unread message

Tony Murphy

unread,
Oct 24, 2023, 2:22:08 PM10/24/23
to mountebank-discuss
I'm trying to find an example of using the value of a query parameter to lookup a response row in a csv. 

Chatgpt says, it's not possible. It suggested I enable javascript and use the decorate behaviour to copy the query param into the body.  However, I don't want to use injection.

Seems odd that this behaviour isn't available 

"_behaviors": {
  "lookup": [{
    "key": {
    "from": "query",
      "using": {
       "method": "regex",
       "selector": "id=(.*)"
      }
     },
     "fromDataSource": {
       "csv": {
       "path": "lookup/responses.csv",
       "keyColumn": "ID"
       }
     },
     "into": "row"
    }]
}

Tony Murphy

unread,
Oct 24, 2023, 3:05:58 PM10/24/23
to mountebank-discuss
Had error in my config, and chatgpt made it worse in this scenario. This works


"lookup"
: [{
  "key": {
  "from": { "query""id" },
  "using": {
    "method""regex",
    "selector""\\d+$"
   }
  },
  "fromDataSource": {
    "csv": {
      "path""
lookup/responses.csv",
      "keyColumn""IF"
     }
   },
   "into""${row}"
}]


Reply all
Reply to author
Forward
0 new messages