Skip to content

Instantly share code, notes, and snippets.

View DannyDainton's full-sized avatar
💭
Probably helping someone...

Danny Dainton DannyDainton

💭
Probably helping someone...
View GitHub Profile
@DannyDainton
DannyDainton / copy_environment.sh
Created March 10, 2026 09:52
This script can be using to move a Postman Environment from a Shared Workspace to an Internal Workspace.
#!/bin/bash
# Copy a Postman Environment to a different workspace
# Create a new Postman API Key for your user https://go.postman.co/settings/me/api-keys and add this to the API_KEY variable
# Usage: ./copy_environment.sh <environment_id> <workspace_id>
set -euo pipefail
API_KEY="POSTMAN_API_KEY"
BASE_URL="https://api.getpostman.com"
@DannyDainton
DannyDainton / copy_collection.sh
Last active March 5, 2026 21:24
This script can be using to move a Postman Collection from a Shared Workspace to an Internal Workspace.
#!/bin/bash
# Copy a Postman Collection to a different workspace
# Create a new Postman API Key for your user https://go.postman.co/settings/me/api-keys and add this to the API_KEY variable
# Usage: ./copy_collection.sh <collection_id> <workspace_id>
set -euo pipefail
API_KEY="POSTMAN_API_KEY"
BASE_URL="https://api.getpostman.com"
@DannyDainton
DannyDainton / postman-cli-runner.yml
Created June 10, 2024 14:47
A basic workflow file that can be used to run your Postman Collection through a GitHub Action using specific configurations. The result are presented in the GitHub Action console and also on the runs section of the Postman Collection.
name: Automated API tests using Postman CLI
run-name: The Collection run was started by ${{ github.actor }}
on:
workflow_dispatch:
inputs:
collection-uid:
required: true
type: string
description: 'The Collection UID for the run'
iterations:
@DannyDainton
DannyDainton / utils.js
Created May 16, 2024 16:36
A list of my reusable functions that I use in Postman's Package Library feature.
/**
* Create a random string length between the speficied min / max values
* @param {Number} minValue - The min value of the string length
* @param {Number} maxValue - The max value of the string length
*/
const randomString = function (minValue, maxValue, dataSet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz') {
const lodash = require('lodash');
if (!minValue) {
minValue = 10;
maxValue = 10;
@DannyDainton
DannyDainton / collapsedHeaders.hbs
Last active August 16, 2020 06:14
A template that can be used with Newman htmlextra which has the request and response headers collapsed by default. To use this template, save locally and add to your Newman command using the `--reporter-htmlextra-template <filename>.hbs` flag
<!DOCTYPE html>
<html lang="en" style="overflow-y: scroll;">
<head>
<meta charset="UTF-8">
<title>{{browserTitle}}</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.13.1/styles/github-gist.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/v/bs4/dt-1.10.18/datatables.min.css"/>
@DannyDainton
DannyDainton / saveToPDF.js
Last active June 2, 2020 10:16
Save a JSON response containing a base64 value to a PDF file within Postman. Added this script to the `Tests` tab and view the response in the Visualiser. Reference post - https://medium.com/younited-tech-blog/serve-yourself-combining-postman-and-express-3fd1dd9f545c
let myPDFData = {
contract: Buffer.from(pm.response.json().contract, 'base64'),
reference: pm.response.json().reference
}
let template = `
<script src="https://unpkg.com/jspdf@latest/dist/jspdf.min.js"></script>
<button onclick="savePDF()">Save To PDF</button>
@DannyDainton
DannyDainton / naughtyStrings.json
Last active February 20, 2024 20:21
The Big List of Naughty Strings (https://github.com/minimaxir/big-list-of-naughty-strings) in a JSON data file that can be used with Postman's Collection Runner. You would only need to add the `{{naughtyValue}}` variable to the request and the Collection Runner will do the rest.
[
{
"naughtyValue": ""
},
{
"naughtyValue": "undefined"
},
{
"naughtyValue": "undef"
},
<html>
<head>
<title>My Awesome Template</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<div class="table-responsive">
<table class="table table-striped table-bordered">
{
"cursor": {
"position": 0,
"iteration": 0,
"length": 1,
"cycles": 1,
"empty": false,
"eof": false,
"bof": true,
"cr": false,
@DannyDainton
DannyDainton / NewmanCustomHTMLReport.hbs
Created November 16, 2018 07:57
The is a custom HTML Report template that can be used with the Postman Newman Collection Runner
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Postman - Reports</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script type="text/javascript">
//custom script