how can we use the POST method in virtual services for dynamic response.

AkshitaAkshita Posts: 3

we want to test the post method with dynamic input and also want the same responce from the virtual service

1) We are using service( https://petstore.swagger.io/v2/pet ) for post method with below request body:

{
"id": 4,
"category": {
"id": 0,
"name": "string"
},
"name": "Avik",
"photoUrls": [
"string"
],
"tags": [
{
"id": 0,
"name": "string"
}
],
"status": "available"
}

if we are changing the value(id, name) in the same request body, we should get response accordingly.

we already achieved for the Get Method of rest services

Comments

  • williammccuskerwilliammccusker ✭✭ Posts: 186 ✭✭

    Hi,

    I am not sure if this answers your question but you can use a responder correlation on the http method to tell the difference between a POST and a GET request. These would be two responders: one correlating for POST and one correlating for GET.

    Did that help answer your question? Please let me know, thanks!

  • AkshitaAkshita Posts: 3

    Yes, it was helpful but whenever we change the data in input(or request body), the response data is same.

    The response data is not changing in virtual service according to the input value

  • williammccuskerwilliammccusker ✭✭ Posts: 186 ✭✭

    Hi,

    There are many ways to achieve this, one way would be to use data banks to extract values from the incoming request payload and parameterize the response with those values. Another way is to setup a data source that has a row for each different set of data you want to send then use a data source correlation on the responder to load a specific row based on the request.

    This overview may be helpful, it mentions data sources and data source correlations
    https://docs.parasoft.com/display/SOAVIRT9104/Message+Responder+Overview#MessageResponderOverview-UsingExistingDataSourcesorRapidlyCreatingDataSourcesforResponses

    Also if you would prefer you can contact support directly by emailing [email protected] and they could help connect you with trains or more hands on guidance.

    Hope this helped!

  • AkshitaAkshita Posts: 3

    Please give me some Data Bank example to better understand the functionality for visualizing the POST REST API.

Sign In or Register to comment.