I am trying to read values from the request using Custom - Responder correlation and compare it with values from excel. How do I get a unique row from excel data source in the script?
I think you probably want this one:
List<String> com.parasoft.api.ScriptingContext.getValues(String dataSourceName, String columnName)
You provide the name of your data source, the name of the column, and then it returns all the values in that data source and column. With that list, you can call get(int index) to get the value at the desired row index (0-based).
It gives null pointer when I try to access the data source. I have tried the above code and got a null. Somehow the same code works in the Extension tool without any issues.
In a responder it doesn't work because at the time that "responder correlations" are run the data source has not yet been set. This is what "datasource correlations" are for. Could you use one of the existing "datasource correlations" options? To compare if a value from the request matches a column in an excel data source you can use "Request Body"
We go over how to use Data Source correlation in this post. There is also a video that goes into the details. Take a look at that and see if that helps you out.