|
|
Create Tasks from Another System
A form, a ticketing tool or a project plan can add tasks to an event's task list. You need the event's id, and
optionally a task section and the person to assign the task to.
1. Find the event
Search by name, or by your own id if you stored it in integration_metadata_field_1 (see
Sync Events and Tasks to Another System).
$return_event_lites=true returns just the essentials, which is faster.
curl "https://api.exhibitday.com/v1/events?filter_by_event_name_contains_text=Expo&%24return_event_lites=true" -H "api_key: YOUR_API_KEY" 2. Pick a section and an assignee (optional)
The event's task sections are in task_sections of /v1/events/info. The people who can be assigned tasks come from
/v1/references/users_and_resources; use their id as assignee_user_id.
curl "https://api.exhibitday.com/v1/references/users_and_resources?filter_by_can_have_tasks_assigned=true" -H "api_key: YOUR_API_KEY" 3. Create the task with an Idempotency-Key
Send a new Idempotency-Key (for example a UUID) with each task you create. If
the call times out, send exactly the same request with the same key: you get the task that was created the first time
(with the header Idempotent-Replayed: true) instead of a second copy. Keys are remembered for 24 hours.
curl -X POST https://api.exhibitday.com/v1/tasks -H "api_key: YOUR_API_KEY" -H "Idempotency-Key: 9b1d4c2e-6f3a-4e8b-a7d5-0c2f1e9b8a64" -H "Content-Type: application/json" -d "{\"name\":\"Order booth carpet\",\"event_id\":12345,\"due_date\":\"2026-10-30\",\"details\":\"Requested from the facilities form\"}"
In Python, with a retry that reuses the key:
import time
import uuid
import requests
def create_task(task):
key = str(uuid.uuid4()) # one key per task; reused for every retry of that task
for attempt in range(3):
try:
response = requests.post("https://api.exhibitday.com/v1/tasks",
headers={"api_key": "YOUR_API_KEY", "Idempotency-Key": key},
json=task, timeout=30)
except requests.exceptions.RequestException:
time.sleep(2 ** attempt) # network error or timeout: retry with the same key
continue
if response.status_code == 429 or response.status_code >= 500 or (response.status_code == 409 and response.json().get("error_code") == "idempotency_key_in_use"):
time.sleep(int(response.headers.get("Retry-After", 2 ** attempt)))
continue
return response.status_code, response.json()
raise RuntimeError("The task could not be created")
status, task = create_task({"name": "Ship the banner stand", "event_id": 12345, "due_date": "2026-10-30"})
print(status, task["id"], task["name"])
Good to know
|