This TypeScript example renames the Content-Type and Content-Length headers using camel case. Renaming headers can be useful for normalizing field names for testing purposes and mapping fields to different data models.
The example uses JSON data from a GET request to postman-echo.com like this:
{
  "body": {
    "args": {},
    "headers": {
      "host": "postman-echo.com",
      "x-request-start": "t1757972551.591",
      "connection": "close",
      "x-forwarded-proto": "https",
      "x-forwarded-port": "443",
      "x-amzn-trace-id": "Root=1-68c88847-aaaaaaaaaaaaaaaaaaaaaaaa",
      "user-agent": "PostmanRuntime/7.46.0",
      "accept": "*/*",
      "cache-control": "no-cache",
      "postman-token": "00000000-1111-2222-3333-444444444444",
      "accept-encoding": "gzip, deflate, br",
      "cookie": "sails.sid=s%3AdummySessionId1234567890.abcdef1234567890"
    },
    "url": "https://postman-echo.com/get"
  },
  "http": {
    "status": 200,
    "headers": {
      "Date": "Mon, 15 Sep 2025 21:42:31 GMT",
      "Content-Type": "application/json; charset=utf-8",
      "Content-Length": "621",
      "Connection": "keep-alive",
      "Server": "nginx",
      "ETag": "W/"26d-FAKEETAG1234567890"",
      "Set-Cookie": "sails.sid=s%3AdummySetCookieId0987654321.qwerty9876543210; Path=/; HttpOnly"
    }
  },
  "tests": [],
  "binary": false
}
The following TypeScript takes the headers from a response variable defined by the Evaluate block. It then maps the Content-Type and Content-Length headers to an object named normalized and renames them using camel case.
const headers = response.http?.headers ?? {};
const normalized = {
  contentType: response.http.headers["Content-Type"],
  contentLength: response.http.headers["Content-Length"]
};
normalized
To see this TypeScript in an example flow, check out TypeScript example 1: Rename headers with camel case.
Last modified: 2025/09/20