If you had returned a non-200, you would have gotten an exception thrown. A 202 is considered a valid return code as it shows the message has been successfully accepted, but has not been completely processed yet. Since there was no error HTTP status code, there would be no APIException thrown.
Thanks,
John
Original Message:
Sent: 05-22-2025 09:56
From: Allan Zhao
Subject: Python code issue when i tried to get_conversation_recordings
Yes, you are right. I already add the loop twice to make sure getting the right response.
It seems python is not good choice for GC development as when there is not recording to the conversation, there is an exception not a response.
------------------------------
Allan Zhao
Original Message:
Sent: 05-22-2025 04:19
From: Harry Boskur
Subject: Python code issue when i tried to get_conversation_recordings
It's expected to return 202 as your request takes time for the recording to process and after sometime it should return you 200 ok with the media uri.
Use a for loop with a variable which tries for 2 or more times with the same conversion ID with a wait time of 1-2 seconds
Check if the responds is empty run it again till you get the response with uri
------------------------------
Harry Boskur
Original Message:
Sent: 05-21-2025 23:51
From: Allan Zhao
Subject: Python code issue when i tried to get_conversation_recordings
every time when i tried to get the recording by the conversation_id. I will get nothing at the first time then i tried the 2nd time, it works.
try:
api_response = recordApi.get_conversation_recordings(
conversation_id,
max_wait_ms=max_wait_ms,
format_id=format_id,
media_formats=media_formats,
)
uri = api_response[0].media_uris["0"].media_uri
return render_template("recording.html", data=uri)
except ApiException as e:
print(
"Exception when calling RecordingApi->get_conversation_recordings: %s\n" % e
)
then i tried on the develop tools, by using api/v2/conversations/{conversationId}/recordings
i found that the first time it returned code 202, next time when i called the i will get the correct response
so i want to know how can i optimize my python code, because i can't get anything when i called api at first time even response code
Regards,
Allan
#PlatformAPI
#PlatformSDK
------------------------------
Allan Zhao
------------------------------