Created
October 11, 2021 20:39
-
-
Save chand1012/c5315071600002993bc3877ee27fbd34 to your computer and use it in GitHub Desktop.
POSTs a JSON file as a request body to the specified URL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import json | |
import sys | |
# first argument is the url | |
# second argument is the file name | |
url = sys.argv[1] | |
file_name = sys.argv[2] | |
# load json file with test data | |
with open(file_name) as json_file: | |
data = json.load(json_file) | |
# post the gotten json data to the server | |
r = requests.post(url, json=data) | |
# print the response text to console | |
print(r.text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment