Skip to content

Commit 71fdb82

Browse files
committed
CR improvements
1 parent 37be80e commit 71fdb82

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

examples/pushData/pushData.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,25 @@
22
from databox.rest import ApiException
33
from pprint import pprint
44

5+
# Configuration setup for the Databox API client
6+
# The API token is used as the username for authentication
7+
# It's recommended to store your API token securely, e.g., in an environment variable
58
configuration = databox.Configuration(
69
host = "https://push.databox.com",
710
username = "<YOUR-CUSTOM-DATA-TOKEN>",
811
password = ""
9-
)
10-
12+
)
1113
with databox.ApiClient(configuration, "Accept", "application/vnd.databox.v2+json",) as api_client:
1214
api_instance = databox.DefaultApi(api_client)
15+
1316
push_data = [{"key": "sales2", "value": 100, "unit": "USD", "date": "2021-01-01T00:00:00Z" }]
17+
1418
try:
1519
api_instance.data_post(push_data=push_data)
20+
except ApiException as e:
21+
# Handle exceptions that occur during the API call, such as invalid data or authentication issues
22+
pprint("API Exception occurred: %s\n" % e)
1623
except Exception as e:
17-
print("Exception: %s\n" % e)
24+
# Handle any other unexpected exceptions
25+
pprint("An unexpected error occurred: %s\n" % e)
1826

0 commit comments

Comments
 (0)