INPUT
Post request
OUTPUT
To send a POST request in Python, you can use the requests
library. Here's an example code snippet that demonstrates how to make a POST request:
import requests # Define the API endpoint and payload url = '<API_ENDPOINT_URL>' payload = { 'key1': 'value1', 'key2': 'value2' } # Send the POST request response = requests.post(url, data=payload) # Check the response status code if response.status_code == 200: print('POST request successful') else: print('POST request failed')
In the above code snippet, replace <API_ENDPOINT_URL>
with the actual URL of the API endpoint you want to send the POST request to. Modify the payload
dictionary to include the required data for your specific API.
Note that the requests
library needs to be installed for this code snippet to work. You can install it using pip:
pip install requests
Remember to import the requests
module at the beginning of your script.