You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
723 B
Python

import requests
def call_api(api_url, method, params):
"""
Function to make an API call.
Parameters:
- api_url (str): The URL of the API endpoint.
- method (str): The HTTP method to use ('POST' or 'GET').
- params (dict): Dictionary of parameters.
Returns:
- response: The response from the API call.
"""
print("Calling API",api_url,"with method",method,"and parameters",params)
if method.upper() == 'POST':
response = requests.post(api_url, data=params, verify=False)
elif method.upper() == 'GET':
response = requests.get(api_url, params=params, verify=False)
else:
raise ValueError("Method must be 'POST' or 'GET'")
return response