Forum Discussion

sivajcet530's avatar
2 years ago

How to get data requested from request body retrieve data from DataSource in service virtualization

1. Send accountNumber in request body.

2. Create database table with accountNumber, Name, Address

3. I created a script to read the data from request body and placed it in OnRequest Script

def reqString = mockRequest.getRequestContent()
def inputAccNo= reqString .substring(22)
log.info inputAccNo

4. Created connection to the table created in step2 in "Data Sources" table in Ready API (Virtual) service.

Could you please help how to pass the inputAccNo to get appropriate data (accountNumber, Name, Address) from data source?

If I send inputAccNo 10001 it should give response as 10001,XNAME,XADDRESS, If I send 1002 it should get data from DB and give response as 10002,YNAME,YADDRESS

No RepliesBe the first to reply