Forum Discussion

jas_Jas's avatar
Established Member
5 years ago

How to use properties( either mock service or project) in resource path of mockService?



I  want to use custom properties of mock service or project as variable in mock service resource path. Any way to do it ?

Test Case Endpoint: http://localhost:9100/v1/customers - it send authorization as header which contain token to be used by mock service. Mock service running on : Mock Service End Point:
/customer/101068577 /customer/101068577/loyalty/relationship


I am able to transfer property from project level to mock service, but unable to use mock service property in resource path.



Mock service unable to read value from mockService custom property.


mock service resource url : /customer/${#mockService#Customer_ID_Default} /customer/${#mockService#Customer_ID_Default}/loyalty/relationship

or /customer/${#Project#Customer_ID_Default} /customer/${#Project#Customer_ID_Default}/loyalty/relationship


1 Reply

  • JHunt's avatar
    Community Hero

    Create a MockAction for GET with the resource path set to /customers. For Dispatch type, choose "Script". The script will look something like this:


    String defaultCustomer= mockOperation.mockService.getPropertyValue('Customer_ID_Default')

    if (mockRequest.path == "/customers/${defaultCustomer}") { return "Response 1" // return the name of the mock response to send