Simulating REST Service with Different uri parameter

Is it possible to simulate a rest service that has a parameter in the uri. 

For example, 




I cannot see how to do this in SV, is it possible to handle dynamic request uri's?



  • Suggested Answer

    Yes, it is possible. REST VS is very flexible, which however also means care should be taken when you are designing one.

    First decision you should make is to choose which part of the request URL identifies the service and which one has the meaning of operations and parameters. The service part should be put into VS configuration and the rest of the path will be available in a DM (Data Model).

    Let's take your sample URLs as an example. It looks like getCustomer might be identifying the operation as I assume, there might be URLs, which would have saveCustomer or deleteCustomer values there and it just makes sense to handle related logic in one VS. This means, we'll have to do the split right after the <host>. This means, that you need to put https://<host>/ into the VS configuration and that you should probably name the service something like "Customer Service" . Then once you do the learning,  remaining part of the URL, which is not in the VS configuration will be available in the Request/HTTPInputParameters/UriPath field (e.g. "getCustomer/07533") and you can put regular Is condition on it and choose appropriate response based on this condition.

    BTW you should probably created dedicated operation getCustomer/* to split the data before you do the learning, so possible message structures for additional operations like saveCustomer  or deleteCustomer  don't get mixed up. You can do this by clicking on the default catch-all ** operation and selecting Add URI Space

  • Thanks Jakub for your reply, but can I ask for help on this. 

    I did not mention, but I am hand scripting this in SV as I cannot learn the service. I am using the Default Response Rule within the Data Model. 

    One issue is that I cannot edit the fields in the Request part of the rule, they are greyed out. I got a popup to say that "Not Present is set on Parent....."

    Can you explain how I change this on the "Parent" so these fields are editable?


    Apologies if these are basic questions, but I am a newbie, as you know. 

  • Hand scripting this is fine, but you should do that in a dedicated rule.

    Default response is for cases when there is nothing better to send back. You can modify default response data, but it has some limitations. For example you cannot set conditions on request data, which is something you want to do. You also cannot have more then one response for response type, which again is something you have. Therefor please create new Data Rule and put your data there.

    If you haven't done so already, I would suggest you check this YouTube playlist, which explains basic data modeling concepts: