Skip to content

sahaj-b/multiple-curl-to-postman

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Convert multiple cURL requests to a Postman collection

If you have multiple cURL requests that you want to import to Postman at once, this script will help you achieve that.

This script makes use of cURL to Postman module and Collection SDK module to achieve this.

This is a fork of bhargavkaranam/multiple-curl-to-postman

This fork adds:

  • Support for converting bash file with multiple cURL commands to a postman collection (see this section)
  • Validation for cURL commands
  • --save and --collection-name flags

Installation

git clone https://github.com/sahaj-b/multiple-curl-to-postman.git
cd multiple-curl-to-postman
npm install

Usage

Convert from standalone cURL commands using --curl

node index.js --curl "curl -X GET \
  'http://postman-echo.get?foo=bar&batman=joker' \
  -H 'Postman-Token: 1a88e7fd-5b67-434c-aaf8-90ed9bfc3d46' \
  -H 'cache-control: no-cache' \
  -H 'content: application/json'" \
  --curl "curl -X POST \
  http://postman-echo.com/post \
  -H 'Content-Type: application/json' \
  -H 'Postman-Token: e6a3a3d7-4a55-4dd8-a080-6ad7e425a9b0' \
  -H 'cache-control: no-cache' \
  -d '{
        \"a\": 1,
        \"b\": 2
  }'"

Convert from bash file

node index.js --file path/to/file.sh

Format for .sh file:

# Request Name 1
curl_command_1

# Request Name 2
curl_command_2

#....

Check commands.sh file for examples

Important

The script automatically removes -L flag and replaces --data-raw with -d flag from the cURL commands in bash file

Note

This fork doesn't save to file by default, it just outputs the collection to console

Use --save FILE flag to save the collection to a file

Use --collection-name NAME flag to set the collection name

About

Convert multiple cURL requests to Postman collection

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 80.0%
  • Shell 20.0%