cancel
Showing results for 
Search instead for 
Did you mean: 

serviceV how to get resource path parameter in script

SOLVED
Occasional Contributor

serviceV how to get resource path parameter in script

How I am able to use resource parameter in dispach script? For example I have mock REST service "context/{resourceID}/otherPath"

What I want to use is the "resourceID" in my response. So I need read the value form request. But no idea how to do this.

Proper response is selected - there can be just one. In this response is inline script for reading project propertie. 

But how to put value in to project propertie???

 

Any idea?

Thanks a lot in advance for your advice.

1 ACCEPTED SOLUTION

Accepted Solutions
Occasional Contributor

Re: serviceV how to get resource path parameter in script

I am parsing request resource path in my response in script like this:

my MOCK operation is: POST submit/{ORI}/method

and how I am getting ORI value in my response is done by this script. Then value is used in future in response..

But I hope there must be more comfortable way, how to get this..

def requestPath = mockRequest.getPath()
log.info "Path: "+ requestPath

requestPath = requestPath.replace("/submit/", "")
def ORI = requestPath.substring(0, requestPath.indexOf("/"))
log.info "ORI: " + ORI

return
1 REPLY 1
Occasional Contributor

Re: serviceV how to get resource path parameter in script

I am parsing request resource path in my response in script like this:

my MOCK operation is: POST submit/{ORI}/method

and how I am getting ORI value in my response is done by this script. Then value is used in future in response..

But I hope there must be more comfortable way, how to get this..

def requestPath = mockRequest.getPath()
log.info "Path: "+ requestPath

requestPath = requestPath.replace("/submit/", "")
def ORI = requestPath.substring(0, requestPath.indexOf("/"))
log.info "ORI: " + ORI

return
New Here?
Join us and watch the welcome video:
Join the exciting event
SeptemberHubBub
Top Kudoed Authors
Join the September Hub-bub to show off, learn and win