Manage and use datasets in scripts
The pm.datasets function provides access to datasets from a script or code mock. You can query datasets using SQL to retrieve data when your script or code mock runs. This enables your scripts and code mocks to return dynamic, data-driven responses instead of static values.
All methods are asynchronous and return Promises, so use await to access their results. Query results return rows as an async iterable, so use the for await...of loop to read the returned rows.
Learn more about using datasets in scripts and code mocks.
The pm.datasets function isn’t supported in the mock code editor in Cloud View.
pm.datasets
The pm.datasets function provides access to datasets from a script or code mock. You can load a dataset by its ID and then use methods to query the dataset or manage views.
pm.datasets(datasetId:String)
Loads a dataset and returns a handle you can use to interact with the dataset.
dataset.executeView(viewId:String, params?:String[])
Runs a view that’s already defined in the dataset and returns the results. Query rows are returned as an async iterable, so use the for await...of loop to read the rows.
dataset.executeQuery(sql:String, params?:String[])
Runs a custom SQL query against the dataset and returns the results. Query rows are returned as an async iterable, so use the for await...of loop to read the rows.