Good evening (or morning, or whatever)
So... if I'm reading the docs correctly, the hoops I need to jump through are:
- Get a conversation ID - not an issue
- Get a recording ID from that conversation ID by calling GET /api/v2/conversations/{conversationId}/recordings - here's where it's getting inconsistent and "interesting" - more on that later
- Then there was another call after that to get the actual data of the recording; I think it was just appending the recording ID on the end of the previous URL (actually using the JS SDK so I don't see much of the underlying REST stuff). Works like a charm if step 2 isn't being a flake.
So... step 2... according to the docs, this returns "Recording" (no more information given). And sometimes, that's what it does. It returns an object I can get a recording ID from... other times, it gives me... undefined? Okay..... so my next guess has been to play with it in the new API explorer tool somebody here recommended last week. This gave me... 202 Accepted?
Clearly, I'm either looking in all the wrong places for docs, or there are a few dozen subtle gotchas that my porgram is not currently anticipating. I know really old recordings get deleted, which makes sense, but none of the ones I'm trying to get are that old (most of them from a month or two ago at the latest). So.... how exactly does this thing work? I'm guessing the SDK is actually sending two XHRs under the hood, an OPTIONS and a GET or something (cuz that's the only time I've seen "202 Accepted" ever used anywhere, not to mention there is no data in API explorer when it responds like that). Here's some code, just cuz:
// The variable "recording" is a Genesys "RecordingsApi();" object, created when the page loads.
var step1 = await recording.getConversationRecordings(conversationID);
if (!step1 || !step1[0] || step1[0].fileState != 'AVAILABLE') {
// Here it sometimes throws because step1 is mysteriously "undefined".
// Current theory is that 202 Accepted != an object, no data in response, so #flummoxedAgain
// Of course my logger catches it and tells me that... the question is, what's "dis-defining" my response?
// This code is in a try-catch block, and the previous line seems to run without any errors.....
}
// Whether it gets here is about a 50/50, but I'm pasting it just for context
var step2 = recording.getConversationRecording(id, step1[2 0].id, { "formatId": "WAV", "download": true, "mediaFormats": ["WAV", "OGG_2 VORBIS", "MP3"] });
So....? Haha sorry, this is one of those annoying consistency problems that always leaves me guessing at any random thing that might potentially lead to a whiff of an explanation... So.... I just keep coming back to "So...?" One of my co-workers has gotten to calling it a "Gremlin", and I kinda feel like that's the only logical explanation.
Any ideas?