The PUT /api/v2/interaction-configs/scripts endpoint is consistently returning a 409 Conflict when attempting to sync updated script versions from ServiceNow via our nightly webhook. The payload includes the correct etag from the initial GET request, yet the conflict persists specifically for scripts linked to active digital channel queues. Does anyone know if there is a hidden lock mechanism on scripts with active conversation associations?
Make sure you verify the etag freshness before sending the update request, as digital channel scripts often have shorter cache lifecycles than voice scripts. The 409 conflict usually indicates that the etag from the initial GET request has expired due to concurrent access or background system updates, rather than a hidden lock mechanism. The API documentation suggests implementing a retry loop with a fresh etag fetch on conflict.
import requests
import time
def update_script_with_retry(script_id, payload, max_retries=3):
headers = {"Content-Type": "application/json"}
for attempt in range(max_retries):
# Fetch fresh etag
get_resp = requests.get(f"/api/v2/interaction-configs/scripts/{script_id}", headers=headers)
etag = get_resp.headers.get("ETag")
if not etag:
raise Exception("No ETag returned")
headers["If-Match"] = etag
put_resp = requests.put(f"/api/v2/interaction-configs/scripts/{script_id}", json=payload, headers=headers)
if put_resp.status_code == 200:
return "Success"
elif put_resp.status_code == 409:
time.sleep(1) # Wait before retrying
else:
raise Exception(f"Unexpected status: {put_resp.status_code}")
return "Failed after retries"
This approach ensures the etag is valid at the exact moment of the PUT request, resolving the conflict.