Legacy Dev Forum Posts

 View Only

Sign Up

Historical adherance report

  • 1.  Historical adherance report

    Posted 06-05-2025 18:12

    matthew | 2017-08-30 04:12:10 UTC | #1

    Hi, Apologies for my ignorance here, i'm trying to work out how to retrieve the historical adherance via ;

    /api/v2/workforcemanagement/managementunits/{muId}/historicaladherencequery

    Can you clarify what the muId is? and how this should be used? the doco refers to the logged in user. if this is running from a script, does this mean the api user?

    I wish to get the adherance reports for all agents in the system.

    Thanks.


    tim.smith | 2017-08-30 14:19:07 UTC | #2

    The muId value is the ID of one of the management units returned from GET /api/v2/workforcemanagement/managementunits. The documentation for the parameter states:

    The muId of the management unit, or 'mine' for the management unit of the logged-in user.

    In this context, the "logged-in user" is referring to the user that authorized the auth token used to make the API request to that endpoint. If your goal is to export data for multiple users, get the muIds from the API above and specify the user Ids in the post body for the adherence query.


    Behymer_Joe | 2017-09-05 17:21:13 UTC | #3

    I hope Tim's reply helped you Matthew. I realize the 'mine' replacement for management unit ID is a bit confusing on an endpoint like this. We added it to make it easier to call a "get my schedule" route without having to look up the current users management unit ID.

    When using the historical adherence endpoint, you'll want to make multiple calls for each management unit you have. You can get a list of management units from the route Tim linked above.


    matthew | 2017-09-06 03:42:01 UTC | #4

    hi, yes that is more clear.

    however we are now getting an error whilst using the c# sdk to access this method :

    api.GetWorkforcemanagementManagementunits();

    {"Cannot deserialize the current JSON object (e.g. {\"name\":\"value\"}) into type 'System.Collections.Generic.List`1[PureCloudPlatform.Client.V2.Model.ManagementUnit]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly

    The error seems to come from your sdk. Can you help us check this please?

    thanks.


    tim.smith | 2017-09-06 13:36:36 UTC | #5

    The contract on that resource was incorrect, but was fixed last week. For some reason, the SDKs didn't build on the last API deploy, so I've kicked off the builds manually. There should be a new version published within the hour that should contain the fix.


    tim.smith | 2017-09-06 14:50:56 UTC | #6

    Try with v17.0.0+ https://www.nuget.org/packages/PureCloudPlatform.Client.V2/


    matthew | 2017-09-07 05:27:59 UTC | #7

    HI, Yes the method now returns the management units.

    Now onto the main call we are struggling with the WfmHistoricalAdherenceResponse object. In the documentation it says the downloadURL "will return unpopulated but will be populated in the notification" how do we detect the notification? Is there another method we need to call to check the status of the request? Or do we continuously perform the same post until its populated?


    tim.smith | 2017-09-07 14:19:14 UTC | #8

    You will need to use the notification service. Specifically, register for the topic v2.users.{id}.workforcemanagement.historicaladherencequery and connect your websocket prior to initiating the query.


    matthew | 2017-09-08 08:44:03 UTC | #9

    Hi Tim - thanks for that. we tried to set this up and subscribed to that topic in the notifications, but we got no response to say it completed.

    we used this line ; h.AddSubscription("v2.users.{" + u.Id + "}.workforcemanagement.historicaladherencequery", typeof(WfmHistoricalAdherenceCalculationsCompleteNoticeNotification));

    looped through for all users, added the notificationhandler in, and then finally ran the method

    api.PostWorkforcemanagementManagementunitHistoricaladherencequery

    How long should these reports take? We waited over 10 minutes, but got no notification.

    any idea?

    thanks.


    tim.smith | 2017-09-08 15:18:57 UTC | #10

    The brackets are meant to indicate the section that is to be replaced. Do not include them in your topic name.


    matthew | 2017-09-11 01:43:06 UTC | #11

    I've removed the brackets from the subscription topic, but it has not been in following function for a long time. ((NotificationHandler)hh).NotificationReceived += (data) => { if (data.GetType() == typeof(WfmHistoricalAdherenceCalculationsCompleteNoticeNotification)) { var notificationdata = (WfmHistoricalAdherenceCalculationsCompleteNoticeNotification)data;

    WebClient wc = new WebClient(); wc.DownloadData(notificationdata.DownloadUrl);

    }

    }; any idea?


    tim.smith | 2017-09-11 14:24:47 UTC | #12

    To determine if it's an issue with your code or if the events are not getting raised, try subscribing to the notification topic using the Developer Tools Notification Tester and compare activity between your app and the dev tools.


    matthew | 2017-09-13 02:14:05 UTC | #13

    hi when I am debugging program for receiving data by the Notification service ,I notice that data is transmitted have four items, including Eventbody,that just include the downloadURL. this downloadURL is what we want to get, but the data types are as follows, we are unable to get downloadurl included in Eventbody . public interface INotificationData { string TopicName { get; set; } string Version { get; set; } Metadata Metadata { get; set; } } How do I do it to get downloadurl ? thanks


    matthew | 2017-09-20 07:04:29 UTC | #14

    I already solved it.thanks The solution is as follows : PureCloudPlatform.Client.V2.Extensions.Notifications.NotificationData<PureCloudPlatform.Client.V2.Model.WfmHistoricalAdherenceCalculationsCompleteNoticeNotification> d = (PureCloudPlatform.Client.V2.Extensions.Notifications.NotificationData<PureCloudPlatform.Client.V2.Model.WfmHistoricalAdherenceCalculationsCompleteNoticeNotification>)data;


    tim.smith | 2017-09-14 01:34:29 UTC | #15

    There is documentation and sample code under the heading NotificationHandler Helper Class here: https://developer.mypurecloud.com/api/rest/client-libraries/dotnet/. The topic-class mappings are in this file as well as the NotificationTopics class in the SDK.


    matthew | 2017-09-20 06:56:08 UTC | #16

    We got the requests and responses working. But we see it takes a long time for the reports to come back. In some cases several hours before we get a response. Can you advise on the typical time needed to generate these reports?

    thanks.


    Drew_Banin | 2017-09-20 14:06:47 UTC | #17

    I'm trying to pull historical adherence using the Python SDK, but the response from

    POST /api/v2/workforcemanagement/managementunits/abc123.../historicaladherencequery

    does not contain a downloadUrl. I'm seeing:

    {
       'download_url': None,
       'id': '2dda...399',
       'query_state': 'Processing'
    }

    The code I'm using comes straight from the docs here:

    body = PureCloudPlatformClientV2.WfmHistoricalAdherenceQuery() 
    body.start_date = '2017-09-01'
    body.end_date = '2017-09-02'
    
    
    # Request a historical adherence report
    api_response = api_instance.post_workforcemanagement_managementunit_historicaladherencequery(mu_id, body=body)

    I've also tried hitting this endpoint directly in Postman but I don't see the download url there either. Does it look like I'm doing anything incorrect?


    tim.smith | 2017-09-20 14:20:44 UTC | #18

    matthew, post:16, topic:1734
    Can you advise on the typical time needed to generate these reports?

    I don't believe there's an SLA on how long it takes to generate a report. If you believe the time is unacceptable, please open a ticket with PureCloud Support to report the issue.


    tim.smith | 2017-09-20 14:26:31 UTC | #19

    Drew_Banin, post:17, topic:1734
    I'm trying to pull historical adherence using the Python SDK, but the response from

    POST /api/v2/workforcemanagement/managementunits/abc123.../historicaladherencequery

    does not contain a downloadUrl. I'm seeing:

    Please read through this thread. This has already been answered. If you're having trouble using the notification service, please create a new post with your issue.


    system | 2017-10-21 14:21:43 UTC | #20

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