Forum Discussion

raghuk's avatar
raghuk
Occasional Visitor
9 years ago

REST Virtual Svc Response - parameterized variable not replaced in Response

I am using ServiceV Pro's "Sample Virtualization Project" (RESTMockService)

 

In the "GET Search" Action, the Dispatcher script calls the "Wildcard Response" response

if (searchstring == "all")

 

I go to the "Wildcard Response" and would like to return a custom value that is set to a variable

{
"id": "4",
"description": "${item4description}",
"price": "4"
},

 

I write a Response Script for "Wildcard Response" which does

def item4description = "My value from Response Script"

 

When  I start the Virtual Service and call the virtual service using

http://localhost:8089/search?searchstring=all

 

I get 

      {
        "id": "4",
        "description": "",
        "price": "4"
      },

 

Can someone please help and let me know why it is not substituting the value of the variable for json responses?

 

Thanks

Raghu

 

 

1 Reply

  • SChowdhury3's avatar
    SChowdhury3
    Occasional Visitor

    I think the easiest thing  would be to add a custom property named item5description on the mock service and refer that from the json response content like

     

    "description": "${MockResponse#item5description}"

     

    Regards,

    Shadid