Skip to content

Commit

Permalink
CR improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
tvolge committed Sep 3, 2024
1 parent 37be80e commit 71fdb82
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions examples/pushData/pushData.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,25 @@
from databox.rest import ApiException
from pprint import pprint

# Configuration setup for the Databox API client
# The API token is used as the username for authentication
# It's recommended to store your API token securely, e.g., in an environment variable
configuration = databox.Configuration(
host = "https://push.databox.com",
username = "<YOUR-CUSTOM-DATA-TOKEN>",
password = ""
)

)
with databox.ApiClient(configuration, "Accept", "application/vnd.databox.v2+json",) as api_client:
api_instance = databox.DefaultApi(api_client)

push_data = [{"key": "sales2", "value": 100, "unit": "USD", "date": "2021-01-01T00:00:00Z" }]

try:
api_instance.data_post(push_data=push_data)
except ApiException as e:
# Handle exceptions that occur during the API call, such as invalid data or authentication issues
pprint("API Exception occurred: %s\n" % e)
except Exception as e:
print("Exception: %s\n" % e)
# Handle any other unexpected exceptions
pprint("An unexpected error occurred: %s\n" % e)

0 comments on commit 71fdb82

Please sign in to comment.