How to add a custom header to Ajax TruClient script

  • KM00702517
  • 06-Jan-2014
  • 06-Jan-2014

Summary

Example of how to add your own header to the requests of an Ajax TruClient script.

Question

This article gives an example of how to add your own custom header to the Ajax TruClient requests.

Answer

Use the Utils.addAutoHeader API that comes with Ajax TruClient.

Utils.addAutoHeader (header, value, merge);

  • header: The name of the header to be added.
  • value: The value of the header to be added.
  • merge: True value indicates to merge the value with an existing header by the same name, false indicates to overwrite it.

In Development mode of the script, add a "Evaluate JavaScript" step with the required parameters.

Example:

Utils.addAutoHeader

In order to stop adding the custom header to your requests, use "Utils.removeAutoHeader(header)", where header is the name of the header to be removed.