Legacy Dev Forum Posts

 View Only

Sign Up

Bulk recordings export to S3

  • 1.  Bulk recordings export to S3

    Posted 06-05-2025 18:18

    jscripthelp | 2021-02-23 16:56:14 UTC | #1

    I’m trying to run a script for exporting our calls to s3. I’m receiving an error from cloudfront:

    Here's the error: { status: 400, statusText: undefined, headers: { 'content-type': 'application/json', 'content-length': '198', connection: 'close', date: 'Fri, 19 Feb 2021 04:09:25 GMT', 'inin-correlation-id': 'hidden', 'strict-transport-security': 'max-age=600; includeSubDomains', 'cache-control': 'no-cache, no-store, must-revalidate', pragma: 'no-cache', expires: '0', 'x-cache': 'Error from cloudfront', via: '1.1 d5462dd4ef6298c414e47ebf5881a62b.cloudfront.net (CloudFront)', 'x-amz-cf-pop': 'MIA3-C5', 'x-amz-cf-id': 'OMZLuxj5gCKJwteUh8TndJsIZJfqvHPXfJ7V44OD8dJL9NOys9GQ==' }, body: { message: 'The request could not be understood by the server due to malformed syntax.', code: 'bad.request', status: 400, contextId: 'hidden', details: [], errors: [] }, text: '{"message":"The request could not be understood by the server due to malformed syntax.","code":"bad.request","status":400,"contextId":"hidden","details":[],"errors":[]}',


    tim.smith | 2021-02-23 17:24:52 UTC | #2

    Without any information about your request or what resource you're using, all I can say is that your request body is malformed in some way. Review how you're constructing the request and compare it to the documentation for the API resource you're using to find what's incorrect about the request.


    jscripthelp | 2021-02-23 18:00:50 UTC | #3

    Hi Tim, I repurposed the node.js code in your tutorial, for some reason I cannot post on here due to a 2 link limit for new user...can someone remove this limit so I can post the script?

    Thanks


    tim.smith | 2021-02-23 19:35:09 UTC | #4

    You can increase your trust level on the forum and remove the link restriction by spending a bit more time reading posts on the forum. Your statistics are tracked on your profile page. The criteria for earning higher trust levels are outlined here: https://blog.discourse.org/2018/06/understanding-discourse-trust-levels/

    If you can post the code you're using to make this request and provide the correlation ID from the response, that would be helpful.


    jscripthelp | 2021-02-23 20:02:43 UTC | #5

    Tim, I'm a customer. Reached out to my rep, who told me to start a ticket, started a ticket and support told me to reach out on the forum, reach out on the forum and I can't even paste a code sample...


    jscripthelp | 2021-02-23 20:06:32 UTC | #6

    Just trying to figure out how to best utilize this code: https://developer.mypurecloud.com/api/tutorials/recordings-bulk-actions/index.html?language=nodejs&step=1

    Think I've got it going but want to make sure


    tim.smith | 2021-02-23 20:06:37 UTC | #7

    Understood. The trust levels are an anti-spam feature. You'll be able to post once you read a few more posts. The stats on your profile are showing that you're almost there. I'm happy to take a look at your request as soon as you can post it and/or a correlation ID.


    jscripthelp | 2021-02-23 20:13:05 UTC | #8

    Look like my trust level is higher now. Here's the code I''m running locally:

    const platformClient = require('purecloud-platform-client-v2');

    // Credentials const clientId = 'HIDDEN'; const clientSecret = 'HIDDEN';

    // API Instances const recordingApi = new platformClient.RecordingApi();

    // Globals let newJob = null;

    const client = platformClient.ApiClient.instance; client.loginClientCredentialsGrant(clientId,clientSecret) .then(()=> { return createRecordingBulkJob(); }) .then((job) => { console.log('Succesfully created recording bulk job');

    newJob = job; return waitOnJobProcessing(newJob.id); }) .then(() => { console.log('Job is now ready: ' + newJob.id);

    return executeJob(newJob.id); }) .then(() => { console.log('Succesfully execute recording bulk job');

    /* return recordingApi.deleteRecordingJob(newJob.id); }) .then(() => { console.log('Succesfully cancelled recording bulk job'); */ return getRecordingJobs(); }) .then((result) => { console.log(result);

    console.log('Succesfully get recording bulk jobs') }) .catch((err) => { console.log(err); });

    function createRecordingBulkJob(){ return recordingApi.postRecordingJobs({ action: 'EXPORT', // set to "EXPORT" for export action actionDate: '2020-01-01T00:00:00.000Z', integrationId: 'HIDDEN', // Only required when action is EXPORT includeScreenRecordings: true, conversationQuery: { interval: '2015-01-01T00:00:00.000Z/2021-18-02T00:00:00.000Z', order: 'asc', orderBy: 'conversationStart' } }) }

    function waitOnJobProcessing(id){ // Initial state of job is PROCESSING // Wait every 2sec until job has READY state return new Promise((resolve, reject) => { let timer = setInterval(() => { recordingApi.getRecordingJob(id) .then((jobStatus) => { console.log(State is ${jobStatus.state}.) if(jobStatus.state == 'READY') { resolve(); clearInterval(timer); } }) .catch((e) => reject(e)); }, 2000); }); }

    function executeJob(id){ return recordingApi.putRecordingJob(id, { state: 'PROCESSING' }); }

    function getRecordingJobs(){ return recordingApi.getRecordingJobs({ pageeSize: 25, pageNumber: 1, sortBy: 'userId', // or 'dateCreated' state: 'READY', // valid values FULFILLED, PENDING, READY, PROCESSING, CANCELLED, FAILED showOnlyMyJobs: true, jobType: 'EXPORT' // or 'DELETE' }) }


    tim.smith | 2021-02-23 20:14:30 UTC | #9

    Which one of those requests is failing? Can you provide the correlation ID from the repsonse?


    jscripthelp | 2021-02-23 20:25:04 UTC | #10

    Where can I find that ID?


    tim.smith | 2021-02-23 20:39:34 UTC | #11

    It's in the error body and in the response headers; you redacted it from your original post. (note: correlation id == context id)


    jscripthelp | 2021-02-23 20:41:37 UTC | #12

    Here you go Tim: 7e6d1f74-52f5-43ae-8073-fac2a881c4f3


    tim.smith | 2021-02-23 20:48:12 UTC | #13

    jscripthelp, post:8, topic:10066
    interval: '2015-01-01T00:00:00.000Z/2021-18-02T00:00:00.000Z',

    Your interval is invalid. ISO-8601 dates use the format YYYY-MM-DD, so the month 18 is causing the server to fail to parse the request. The ISO-8601 spec can be found here: https://en.wikipedia.org/wiki/ISO_8601#Calendar_dates. The specific format required is also documented in the description for interval for POST /api/v2/recording/jobs.


    jscripthelp | 2021-02-23 21:30:39 UTC | #14

    Thanks Tim, was able to fix and now I'm getting a permissions error:

    {"message":"Unable to perform the requested action. You are missing the following permission(s): [recording:job:add]","code":"missing.permissions","status":403}

    'inin-correlation-id': '3d9548cf-0d2c-4124-9db6-22bde12f4ee3',


    tim.smith | 2021-02-23 21:33:13 UTC | #15

    The role assigned to the user or client credentials that produced the auth token will need to have that permission assigned. See Roles and permissions overview for more info.


    jscripthelp | 2021-02-26 14:17:13 UTC | #16

    Hi Tim, was able to get the script to execute. Appreciate your help. 48+ hours after running my script I'm not seeing any of the calls land in my S3 bucket. Is there anything in my script that needs adjusting?

    This was the result from running the script:

    State is PENDING.

    State is PENDING.

    State is READY. Job is now ready: b897cfea-5a8f-43ec-baff-eaba4e863294 Succesfully execute recording bulk job { entities: [], pageSize: 25, pageNumber: 1, total: 0, firstUri: '/api/v2/recording/jobs?pageSize=25&pageNumber=1&sortBy=userId&state=READY&jobType=EXPORT&showOnlyMyJobs=true', selfUri: '/api/v2/recording/jobs?pageSize=25&pageNumber=1&sortBy=userId&state=READY&jobType=EXPORT&showOnlyMyJobs=true', lastUri: '/api/v2/recording/jobs?pageSize=25&pageNumber=1&sortBy=userId&state=READY&jobType=EXPORT&showOnlyMyJobs=true', pageCount: 0 } Succesfully get recording bulk jobs


    jscripthelp | 2021-03-01 14:20:30 UTC | #17

    Hi Tim, any idea? Feeling pressure to export these calls for our legal department and would like to fix what I'm doing wrong.


    tim.smith | 2021-03-01 14:25:27 UTC | #18

    jscripthelp, post:16, topic:10066
    total: 0,

    It appears your filter didn't match any conversations that had recordings. Make sure your filter will match conversations and try again. If you're sure there are conversations that should be matching, please open a case with Genesys Cloud Care to investigate the missing data.


    jscripthelp | 2021-03-01 14:28:50 UTC | #19

    Thanks for your reply Tim, I'd like to avoid having to wait 24 hours just to see if my script executed properly. Can you take a look at provide any suggestion? I'd like to just grab all possible calls in our account.

    Thanks,


    tim.smith | 2021-03-01 14:29:59 UTC | #20

    I do not have access to customer data and cannot assess why your query isn't returning results. Care does have this access and can investigate missing data if you open a case with them.


    jscripthelp | 2021-03-01 14:31:47 UTC | #21

    Understood, my question then is does my script in it's current form pull all recordings and metadata ? Is it suppose to?

    Thanks again


    tim.smith | 2021-03-02 16:01:26 UTC | #22

    jscripthelp, post:21, topic:10066
    does my script in it's current form pull all recordings and metadata

    It appears that it should fetch recordings for several years, but as you saw in the response, it's getting zero results. Care can assist in troubleshooting why your data isn't being returned. This isn't something that can be investigated via the forum as I do not have access to your data nor can we discuss private customer data in this public setting.


    thomasgriff | 2021-03-03 09:27:59 UTC | #23

    From what I see is that your request body is incorrectly formed, in some way.


    system | 2021-04-03 09:28:03 UTC | #24

    This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.


    This post was migrated from the old Developer Forum.

    ref: 10066