Discussions

Ask a Question
Back to All

Internal Server Error when Uploading consents with API

Hi, when I create a consent I've the Consent ID and the script. Then I record the consent video and try to upload the video with this function:


API_KEY = os.getenv("DID_API_KEY")
DID_URL = os.getenv("DID_URL")

def upload_consent_video(id, consent_url, name, webhook=None):
"""
	Uploads a consent video to the D-ID API for a specific consent request.
	Parameters:
    id (str): The unique consent ID received from the create_consent API.
    consent_url (str): The URL of the uploaded consent video.
    name (str): The name associated with the consent submission.
    webhook (str): The callback URL to receive status updates.

	Returns:
    dict: JSON response from the API containing:
          - Success message if the upload is successful.
          - Error message if the request fails.
"""
url = f"{DID_URL}/consents/{id}"

payload = {
    "name": name,
    "source_url": consent_url,
    "webhook": webhook
}

headers = {
    "authorization": f"Basic {API_KEY}",
    "accept": "application/json"
}

response = requests.post(url, json=payload, headers=headers)
response.raise_for_status()
return response.json()

Testing:

id = "cst_gQq99mHqfRDvu2BnCNXwF"
consent_url = "https://testingcognixai-2.s3.ap-southeast-2.amazonaws.com/consent_1.mov"
name = "Luke"
webhook = "https://webhook.site/32c0b790-36d4-4b5d-a4e4-6ac65ad8e26f"
result_1 = upload_consent_video(id, consent_url, name, webhook)
print(json.dumps(result_1, indent=4))

Link to my consent video: https://testingcognixai-2.s3.ap-southeast-2.amazonaws.com/consent_1.mov


However, I got this Internal Server Error:

{
"id": "cst_gQq99mHqfRDvu2BnCNXwF",
"created_at": "2025-02-26T04:21:23.507Z",
"modified_at": "2025-02-26T04:23:30.156Z",
"created_by": "google-oauth2|113512389688855780968",
"thumbnail_url": "",
"video_url": "",
"status": "error",
"name": "Luke",
"error": {
"description": "InternalServerError",
"kind": "InternalServerError"
}
}

Is there anyway to fix this error ?