Forum Discussion
- rupert_andersonValued Contributor
Hi,
If you mean can you set up a mock with a resource e.g. /quote/task/{id} so that you can do GET requests like /quote/task/12345. Then I would set the mock up like:
And then to get the id parameter value, use some Groovy script in the Dispatch(Script) e.g.
def id = mockRequest.getPath().split("/")[-1]
log.info "id: " + id
Then you can use the id to selectively return responses:
if (id=="12345") return "Quote12345Response"
Or use it for other tasks or include it in the response etc.
Is this what you mean?
Cheers,
Rupert
- shashankalstNew Contributor
This does not work when deployed as war!
- anil334New Contributor
Please try the below line:
def requestPath = mockRequest.getPath();
def reqPathLastVar = requestPath.substring(requestPath.lastIndexOf("/") + 1);
the above lines worked fine even if if you deploy the war file on server.
Related Content
- 10 years ago