Skip to Content
ScriptingPostman to TC

Convert Postman Script

  • Below is a comprehensive guide for converting Postman scripts to Thunder Client scripts.
  • You can find the complete Thunder Client Scripting API here.

Global Variables

The following global variables are available in scripting.

Postman VariableThunder Client Variable
pmtc
pm.expectexpect
pm.assertassert
btoabtoa
atobatob

Built-in Libraries

The following built-in libraries are available in scripting.

Postman LibraryThunder Client Library
ajvajv
---ajv-formats
---axios
atobatob
btoabtoa
bufferbuffer
chaichai
cheeriotc.loadModule(‘cheerio’)
crypto-jscrypto-js
csv-parse/lib/sync papaparse or use tc.loadModule(‘csv-parse’)
---fs
---http
---https
lodashtc.loadModule(‘lodash’)
momenttc.loadModule(‘moment’)
streamstream
---tough-cookie
tv4tc.loadModule(‘tv4’)
urlurl
utilutil
uuiduuid
xml2jsfast-xml-parser

Request

Request object available properties and methods.

Postman PropertyThunder Client Property
---tc.request.id
---tc.request.name
pm.request.urltc.request.url
pm.request.methodtc.request.method
pm.request.headerstc.request.headers
pm.request.bodytc.request.body
pm.request.url.getQueryParam()tc.request.url.getParam()
pm.request.url.addQueryParams()tc.request.url.setParam()
---tc.request.getHeader()
pm.request.headers.add()tc.request.setHeader()
pm.request.headers.remove()---
---tc.request.setBody()

URL query parameters
// Postman script // Get a query param value const userId = pm.request.url.getQueryParam("userId"); // Add or update a query param pm.request.url.addQueryParams({ debug: "true", });
// Thunder Client script // Get a query param value const userId = tc.request.url.getParam("userId"); // Add or update a query param tc.request.url.setParam("debug", "true");

Response

Response object available properties and methods.

Postman PropertyThunder Client Property
pm.response.codetc.response.status
pm.response.status---
pm.response.responseTimetc.response.time
pm.response.responseSizetc.response.size
---tc.response.contentType
pm.response.json()tc.response.json
pm.response.text()tc.response.text
pm.response.headerstc.response.headers
---tc.response.cookies
---tc.response.getHeader()

Info

Get the additional information of the currently executing request.

Postman PropertyThunder Client Property
pm.info.eventName---
pm.info.iterationtc.info.currentIteration
pm.info.iterationCounttc.info.totalIterations
pm.info.requestIdtc.request.id
pm.info.requestNametc.info.requestName
pm.environment.nametc.info.environmentName
---tc.info.collectionName
---tc.info.folderName

Environments

See the available environment methods between Postman and Thunder Client.

Postman MethodsThunder Client Methods
pm.variables.get()tc.getVar()
pm.variables.set()tc.setVar()
pm.variables.replaceIn()tc.replaceVars()
pm.collectionVariables.get()tc.getVar()
pm.collectionVariables.set()tc.setVar()
pm.environment.get()tc.getVar()
pm.environment.set()tc.setVar()
pm.globals.get()tc.getVar()
pm.globals.set()tc.setVar()
pm.iterationData.get()tc.getVar()

Methods

See the available methods between Postman and Thunder Client.

Postman MethodsThunder Client Methods
pm.cookies.has()---
pm.cookies.get()tc.getCookies()
pm.cookies.jar().set()tc.setCookie()
pm.cookies.jar().getAll()tc.getCookies()
pm.cookies.jar().unset()tc.clearCookies()
pm.cookies.jar().clear()tc.clearCookies()
pm.sendRequest()axios or tc.runRequest()
pm.execution.skipRequest()tc.skipRequest()
postman.setNextRequest()try using tc.skipRequest()
pm.visualizer.set()tc.chartView()
pm.test()tc.test()
pm.expect()expect()

Feedback

  • If you have feedback or need additional features, please contact us on our GitHub  page.
Last updated on