Spaces:
Running
Running
File size: 323 Bytes
098a230 |
1 2 3 4 5 6 7 |
import requests
def call_external_api(url, message, request_body , response_body , api_key=None):
headers = {'X-repello-api-key': f'{api_key}'} if api_key else {}
response = requests.post(url, json={request_body: message}, headers=headers)
response.raise_for_status()
return response.json()[response_body] |