Legacy Dev Forum Posts

 View Only

Sign Up

Having Issues with API auth when dealing with reports

  • 1.  Having Issues with API auth when dealing with reports

    Posted 06-05-2025 18:17

    patrick_gault | 2020-05-04 21:42:03 UTC | #1

    Hello,

    I keep running into issues with the API. Here are a few of the issues.

    1. When getting the list of scheduled report jobs i always end up with nothing. I know I am getting everything right because i get this -

    "{ "entities": [], "pageSize": 25, "pageNumber": 1, "total": 0, "firstUri": "/api/v2/analytics/reporting/schedules?pageSize=25&pageNumber=1", "selfUri": "/api/v2/analytics/reporting/schedules?pageSize=25&pageNumber=1", "lastUri": "/api/v2/analytics/reporting/schedules?pageSize=25&pageNumber=1", "pageCount": 0 }"

    1. I have tried a few times to get the Generate a view export request but every time i get an issue. I have been using this AGENTINTERACTIONDETAIL_VIEW and the below code.

    "{ "name": "TEST", "timeZone": "UTC", "exportFormat": "CSV", "interval": "2020-04-01T12:00:01/2020-04-04T12:00:01.", "period": "P1D", "viewType": "AGENTINTERACTIONDETAIL_VIEW", "filter": { "mediaTypes": [], "queueIds": [], "skillIds": [], "skillGroups": [], "languageIds": [], "languageGroups": [], "directions": [], "originatingDirections": [], "wrapUpCodes": [], "dnisList": [], "sessionDnisList": [], "filterQueuesByUserIds": [], "filterUsersByQueueIds": [], "userIds": [], "addressTos": [], "addressFroms": [], "outboundCampaignIds": [], "outboundContactListIds": [], "contactIds": [], "externalContactIds": [], "externalOrgIds": [], "aniList": [], "durationsMilliseconds": [ { "gt": 0, "gte": 0, "lt": 0, "lte": 0 } ], "acdDurationsMilliseconds": [ { "gt": 0, "gte": 0, "lt": 0, "lte": 0 } ], "talkDurationsMilliseconds": [ { "gt": 0, "gte": 0, "lt": 0, "lte": 0 } ], "acwDurationsMilliseconds": [ { "gt": 0, "gte": 0, "lt": 0, "lte": 0 } ], "handleDurationsMilliseconds": [ { "gt": 0, "gte": 0, "lt": 0, "lte": 0 } ], "holdDurationsMilliseconds": [ { "gt": 0, "gte": 0, "lt": 0, "lte": 0 } ], "abandonDurationsMilliseconds": [ { "gt": 0, "gte": 0, "lt": 0, "lte": 0 } ], "evaluationScore": { "gt": 0, "gte": 0, "lt": 0, "lte": 0 }, "evaluationCriticalScore": { "gt": 0, "gte": 0, "lt": 0, "lte": 0 }, "evaluationFormIds": [], "evaluatedAgentIds": [], "evaluatorIds": [], "transferred": false, "abandoned": false, "answered": false, "messageTypes": [], "divisionIds": [], "surveyFormIds": [], "surveyTotalScore": { "gt": 0, "gte": 0, "lt": 0, "lte": 0 }, "surveyNpsScore": { "gt": 0, "gte": 0, "lt": 0, "lte": 0 }, "mos": { "gt": 0, "gte": 0, "lt": 0, "lte": 0 }, "surveyQuestionGroupScore": { "gt": 0, "gte": 0, "lt": 0, "lte": 0 }, "surveyPromoterScore": { "gt": 0, "gte": 0, "lt": 0, "lte": 0 }, "surveyFormContextIds": [], "conversationIds": [], "sipCallIds": [], "isEnded": false, "isSurveyed": false, "surveyScores": [ { "gt": 0, "gte": 0, "lt": 0, "lte": 0 } ], "promoterScores": [ { "gt": 0, "gte": 0, "lt": 0, "lte": 0 } ], "isCampaign": false, "surveyStatuses": [], "conversationProperties": { "isWaiting": false, "isActive": false, "isAcd": false, "isPreferred": false, "isScreenshare": false, "isCobrowse": false, "isVoicemail": false, "isFlagged": false, "isMonitored": false, "filterWrapUpNotes": false, "matchAll": false }, "isBlindTransferred": false, "isConsulted": false, "isConsultTransferred": false, "remoteParticipants": [], "flowIds": [], "flowOutcomeIds": [], "flowOutcomeValues": [], "flowDestinationTypes": [], "flowDisconnectReasons": [], "flowTypes": [], "flowEntryTypes": [], "flowEntryReasons": [], "flowVersions": [], "groupIds": [], "hasJourneyCustomerId": false, "hasJourneyActionMapId": false, "hasJourneyVisitId": false, "hasMedia": false, "roleIds": [], "reportsTos": [], "locationIds": [], "flowOutTypes": [], "providerList": [] }, "read": false, "locale": "", "hasFormatDurations": false, "hasSplitFilters": false, "selectedColumns": [ { "columnOrder": 0, "columnName": "" } ], "hasCustomParticipantAttributes": false }"

    1. Last is "get a scheduled report job using Scheduled ID". In the API wizard I can get it to work but when i try using postman or doing it myself I cannot get it to work unless I use the token that the API wizard gave me. So it seems that I do not have any permissions in my oAuth but i can download the report and do everything else, just not get the list.

    /api/v2/analytics/reporting/schedules/{scheduleId}

    Thank you for the help! Patrick


    Jerome.Saint-Marc | 2020-05-06 17:31:37 UTC | #2

    Hello,

    [1] We cannot investigate customer-specific data via the forum so it is difficult to say.

    When you are running the query to get a list of scheduled report jobs, are you doing this from the API Explorer in the developer tools? Or are you making this query using an app (using Client Credentials grant)?

    If you are using the API Explorer: When you are logged in your PureCloud Web client, do you see the Reports menu? And when you select this Menu, do you see any created reports there (which had been defined with a Report Generation Time set to Now or to Schedule)?

    If no, then that would explain why you don't get any results in your request. If yes, I would suggest to open a case with Genesys Cloud Care to investigate the missing data.

    [2] The structure (body) that you are using in your "Generate a view export request" is not correct.

    The interval attribute is not properly formatted.

    The locale attribute is mandatory (you can set it to en-us, en_US, fr, ...).

    The AGENTINTERACTIONDETAIL_VIEW has a mandatory filter on userIds. You need to add the userIds of the agents you want to report on. Minimum is one.

    The JSON schema you used (I assume taken from https://developer.mypurecloud.com/api/rest/v2/analytics/index.html ) needs to be modified and can't be used as is. I mean that it shows what you can set, but it mustn't be used as is. As an example, keeping {"gt": 0, "gte": 0, "lt": 0, "lte": 0} for durationsMilliseconds would mean that you want the duration to be greater than zero, greater or equal to 0, lower than zero, lower or equal to zero. So you just have to keep the one you want (just one) based on the comparison you need (greater, greater or equal, ...). Same goes with the attributes related to score (ex: surveyTotalScore). And with the conversationProperties (that you set to false).

    Here is an example of a body that would work (replacing userIdofthe agentyouwanttoreport_on with a userId of an agent in your system).

    { "name": "TEST01", "timeZone": "UTC", "exportFormat": "CSV", "interval": "2020-04-01T12:00:01.000Z/2020-04-04T12:00:01.000Z", "period": "P1D", "viewType": "AGENTINTERACTIONDETAILVIEW", "filter": { "userIds": ["userIdofthe agentyouwanttoreporton"] }, "locale": "en-us" }

    As note, you can see which fields are mandatory for the different reports running a GET/api/v2/analytics/reporting/exports/metadata (Get all export metadata).

    Once you have requested to generate a view export request, you can get all view export requests for a user, using GET /api/v2/analytics/reporting/exports

    Under the entities array attribute, you will find the different reports you requested.

    You can match the one you requested using the id you got back when doing the request to "Generate a view export request". Or by name if you want.

    It is important to do this as each report under entities will have a status attribute. If its value is equal to "SUBMITTED", it means the PureCloud org is still generating/computing the report. Once the status value becomes "COMPLETED", it means the report is ready. You will then see an additional attribute "downloadUrl", which contains the url where to download that report.

    { "entities": [ { "id": "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx", "name": "TEST01", "status": "COMPLETED", "timeZone": "UTC", "exportFormat": "CSV", "interval": "2020-04-01T12:00:01.000Z/2020-04-04T12:00:01.000Z", "downloadUrl": "theurlfordownload", "viewType": "AGENTINTERACTIONDETAILVIEW",

    [3] If by API Wizard, you mean the API Explorer in the developer tools.

    I am not sure what this means here: "when i try using postman or doing it myself..." Are you still using a token that you obtained via a Login flow (OAuth flow - with an OAuth client defined in the PureCloud configuration)? If yes, was it using a Client Credentials Grant (OAuth client set to Grant Type = Client Credentials)?

    The /api/v2/analytics/reporting/schedules/{scheduleId} requires an access token. This request only works for user credentials (Implicit Grant or Authorization Code Grant). It does not work when using client credentials (Client Credentials Grant).

    Same goes with the download of a scheduled report. It appears to be restricted to user credentials (Implicit Grant or Authorization Code Grant). It does not work when using client credentials (Client Credentials Grant).

    See here for an older post on similar topic: https://developer.mypurecloud.com/forum/t/automatic-download-of-xlsx-reports-using-the-api/4842/2 As Tim suggested in this post, if you are trying to run these queries with an application that uses Client Credentials Grant, I would suggest to open a case with GenesysCloud care to report this (so that a more specific HTTP status code is sent back - to make the reject more meaningful).

    Regards,


    system | 2020-06-06 17:40:41 UTC | #3

    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: 7714