Sending requests using scripts
You can run a Calendar Planning tasks via API using a Python script with the requests library.
Specify the API key value in the APIKEY header field.
To run the script, call the command:
python3 script.py request.json
You can find your Calendar Planning API key in the service interface: go to Settings → Company.
import hashlib import hmac import json import requests import sys import time import urllib3 from urllib.parse import urlencode urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
APIKEY = '
def make_request(method, uri, **kwargs): body = json.dumps(kwargs['json']) if kwargs.get('json') else '' url = SOLVER_URL + uri headers = { 'User-Agent': USER_AGENT }
print("--- Debug Info ---")
print(f"URL for request:{BASE_URL}{PATH}")
print(f"Parameters:{PARAMS}")
print(f"Headers:{headers}")
print(f"URI string for signing:{full_uri_for_signing}")
print("------------------\n")
try:
response = requests.get(
url=f"{BASE_URL}{PATH}",
headers=headers,
params=PARAMS
)
print(f"HTTP/1.1{response.status_code} {response.reason}")
for header, value in response.headers.items():
print(f"{header}: {value}")
except requests.exceptions.RequestException as e:
print(f"An error occurred when executing the request:{e}")
```
- Enter the task ID in the
TASK_IDfield. - Launch the script by running the
python3 script.pycommand.
It must be launched in the command line from the folder with your created script.py file.
If the script doesn't launch, make sure that Python with the requests library is installed on your device. To learn more about the installation, see step 4 of the {#T} section.