Triggering Traces with Postman

Postman is a widely used REST API Development Console that provides support for reusable scripts to enhance the functionality. You can easily integrate it with Tideways Trace Triggering to get Traces for every Postman Request that you send of.

1. Configure Environment

You need to set the Tideways API Key as a variable in the Postman Environment you are using:

tideways_apikey=foobar

The Environment configuration is in the top right of the window and should look like this after editing for the API Key:

2. Set Pre Request Script for Collection

Then change the collection that you want to run Tideways Profiler on to include a pre-request script as described in Postman documentation. The script uses the API Key to create a one time, encrypted hash triggering the Profiler.

var apiKey = pm.environment.get("tideways_apikey");

if (apiKey && apiKey.length > 0) {
    var crypto = require('crypto-js');
    var time = (new Date(Date.now() + 1000*60*5).valueOf())
    var payload = 'method=&time=' + time + '&user=';
    var hash = CryptoJS.HmacSHA256(payload, CryptoJS.MD5(apiKey).toString(CryptoJS.enc.Hex));

    pm.environment.set("tideways_hash", "hash=" + hash.toString(CryptoJS.enc.Hex) + "&" + payload);
}

3. Configure the Request Headers to use Tideways Profiling Hash

Sadly pre request scripts cannot modify the request themselves right now in Postman (there is an open bug / feature request)  That means you need to take one further step and in the headers tab of the request configure the Header "X-Tideways-Profiler" to take on the value {{tideways_hash}} as shown in this screenshot:

Still need help? Write [email protected] Write [email protected]