{"id":15771,"library":"postman-request","title":"Postman Request Client","description":"Postman-request is a maintained fork of the popular, now-abandoned `request` module, specifically developed and used internally by Postman Runtime. Currently at version 2.88.1-postman.48, it does not follow a typical open-source release cadence but is updated as needed for Postman's internal applications. This package provides a simplified API for making HTTP requests, addressing numerous long-standing bugs and adding specific features that were never incorporated into the original `request` project. Key differentiators include fixes for old-style deflate responses, correct URL parameter encoding, enhanced redirect behaviors (especially for 307/308 with Host headers), `content-length` for streaming, improved form-data exception handling, and features like retaining authorization headers on cross-domain redirects and support for extending root CA certificates. It aims to offer a stable and patched alternative for projects still reliant on the `request` API.","status":"active","version":"2.88.1-postman.48","language":"javascript","source_language":"en","source_url":"https://github.com/postmanlabs/postman-request","tags":["javascript","http","simple","util","utility"],"install":[{"cmd":"npm install postman-request","lang":"bash","label":"npm"},{"cmd":"yarn add postman-request","lang":"bash","label":"yarn"},{"cmd":"pnpm add postman-request","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Primarily designed for CommonJS; direct ESM import might require specific configuration or a build step, as shown in the quickstart and examples.","wrong":"import request from 'postman-request';","symbol":"request","correct":"const request = require('postman-request');"},{"note":"Convenience methods like `post` are accessed directly from the main `request` object, not as named exports.","wrong":"import { post } from 'postman-request';","symbol":"request.post","correct":"const request = require('postman-request');\nrequest.post('http://example.com/upload', { form: { key: 'value' } }, (error, response, body) => { /* ... */ });"},{"note":"`defaults` is a method on the `request` function, used to create a new `request` instance with pre-set options.","wrong":"const defaultRequest = require('postman-request').defaults;","symbol":"request.defaults","correct":"const request = require('postman-request');\nconst defaultRequest = request.defaults({ headers: { 'User-Agent': 'my-app' } });"}],"quickstart":{"code":"const request = require('postman-request');\n\nrequest('http://www.google.com', function (error, response, body) {\n  if (error) {\n    console.error('Error:', error);\n    return;\n  }\n  console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received\n  console.log('body length:', body ? body.length : 0); // Print the length of the Google homepage HTML\n});","lang":"javascript","description":"Demonstrates a basic GET request to Google, logging the error, status code, and response body length."},"warnings":[{"fix":"Review existing `request` calls against `postman-request`'s specific bug fixes and added features. Test thoroughly to ensure compatibility, especially for edge cases in HTTP handling.","message":"Original 'request' module is abandoned; 'postman-request' is a fork with bug fixes. While largely compatible, subtle behavioral differences might affect existing code.","severity":"breaking","affected_versions":"*"},{"fix":"Prefer `require()` for consistency. If strict ESM is needed, investigate dynamic `import()` or build tool configurations. For new projects, consider modern Promise-based HTTP clients like `axios` or `node-fetch`.","message":"Legacy API and CommonJS-first design. The underlying `request` API is considered legacy compared to `node-fetch` or `axios`.","severity":"gotcha","affected_versions":"*"},{"fix":"Attach `.on('error', handler)` directly to the `request` call before any `.pipe()` operations to ensure proper error capture for upstream failures.","message":"Stream error handling requires specific placement. When chaining streams, an `error` event listener must be attached *before* piping.","severity":"gotcha","affected_versions":"*"},{"fix":"For new application development not specifically tied to the original `request` API, modern HTTP clients (e.g., `node-fetch`, `axios`) offer more contemporary APIs and features.","message":"Not a general-purpose HTTP client for new projects. While actively maintained by Postman, its primary purpose is internal Postman Runtime needs.","severity":"gotcha","affected_versions":"*"},{"fix":"Ensure environments have up-to-date root CA certificates. For custom CAs, use the `ca` option to provide trusted certificates. Avoid disabling SSL validation (`strictSSL: false` or `rejectUnauthorized: false`) in production due to security risks.","message":"SSL/TLS certificate validation issues can occur. Misconfigured environments or self-signed certificates might lead to errors like 'self signed certificate'.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Ensure your system's root CA certificates are up-to-date. For private/self-signed CAs, pass the certificate authority via the `ca` option in the request configuration. Avoid `strictSSL: false` for security.","cause":"The server's SSL certificate is self-signed or not trusted by the client's CA store.","error":"Error: self signed certificate in certificate chain"},{"fix":"Use `const request = require('postman-request');` for CommonJS environments, which is the module's primary export pattern.","cause":"Incorrect import statement, often when trying to use ESM `import` syntax with a CommonJS module, or destructuring incorrectly.","error":"TypeError: request is not a function"},{"fix":"Ensure your callback function only handles a single invocation. While `postman-request` aims to fix common `request` issues, robust error handling with flags can prevent double invocation: `let called = false; if (!called) { called = true; /* ...handle response... */ }`","cause":"A callback function was invoked multiple times, usually due to an internal error handling path or a malformed server response triggering a secondary error after the initial callback.","error":"Callback was already called."}],"ecosystem":"npm"}