import requests
raw_json_data = { "user_name": "hello", "password": "password1" }
data = { "first_name": "hello", "last_name": "world" }
headers = { 'Authorization': 'Bearer token_value_here' }
response = requests.post('https://path/to/api/url/endpoint', headers = headers, data = data, json=raw_json_data)
print(response.status) #prints the status of request
print(response.content) #prints the content
print(response.json()) #json formatted data if response returns any
In the code snippet, we are sending a request using the python-requests package. You can install the requests package in your python project using the below command
pip install requests
0 Comments