Issue HTTP POSTs
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
README.md
post.py

README.md

post

Python command-line utility that issues HTTP POST commands.

Usage

./post.py [-h] url data [header]
  • url: the URL
  • data: either raw data to post as the request body or the path to a file to read containing this data
  • header (optional): either JSON to post as the request header or the path to a file to read containing header JSON

The response code and anything else returned by the server will be sent to the console.

Optional Flags

  • -j/--json: Helpfully adds {"Content-Type": "application/json"} to the header
  • -n/--no-verify: Skips SSL certificate verification

Setup

You'll need to install requests.

Examples

$ ./post.py https://example.com/real_endpoint test.json
Response: 200
$ ./post.py https://example.com/fake_endpoint test.json
Response: 404
$ ./post.py https://example.com/reset-password '{"username": "your.email@example.com"}' -j
Response: 204

The last example above is equivalent to:

$ ./post.py https://example.com/reset-password '{"username": "your.email@example.com"}' '{"Content-Type": "application/json"}'
Response: 204

License Information

Written by Gem Newman. Website | GitHub | Twitter

This work is licensed under the Mozilla Public License 2.0.

Remember: GitHub is not my CV.