Legacy Dev Forum Posts

 View Only

Sign Up

  • 1.  Workforce_ManagementApi

    Posted 06-05-2025 18:08

    anguye10 | 2023-03-03 22:43:17 UTC | #1

    Hello I tried using the code snippet provided by the API explorer for this endpoint: GET /api/v2/workforcemanagement/businessunits/{businessUnitId}/weeks/{weekId}/schedules

    import PureCloudPlatformClientV2 from PureCloudPlatformClientV2.rest import ApiException from pprint import pprint

    Configure OAuth2 access token for authorization: PureCloud OAuth

    PureCloudPlatformClientV2.configuration.accesstoken = 'youraccess_token'

    or use getclientcredentialstoken(...), getsaml2bearertoken(...) or getcodeauthorizationtoken(...)

    create an instance of the API class

    apiinstance = PureCloudPlatformClientV2.WorkforceManagementApi()

    businessunitid = 'businessunitid_example' # str

    The ID of the business unit

    weekid = 'weekid_example' # str

    First day of schedule week in yyyy-MM-dd format, or 'recent' (without quotes) to get recent schedules

    includeonlypublished = True # bool

    includeOnlyPublished (optional)

    expand = 'expand_example' # str

    expand (optional)

    try:

    Get the list of week schedules for the specified week

    apiresponse = apiinstance.getworkforcemanagementbusinessunitweekschedules(businessunitid, weekid, includeonlypublished=includeonlypublished, expand=expand) pprint(apiresponse) except ApiException as e: print("Exception when calling GetWorkforcemanagementBusinessunitWeekSchedulesRequest->getworkforcemanagementbusinessunitweekschedules: %s\n" % e)

    but I get this error: AttributeError: module 'PureCloudPlatformClientV2' has no attribute 'Workforce_ManagementApi'

    have this been deprecated? what's the alternative?

    Thanks,


    Declan_ginty | 2023-03-06 17:54:34 UTC | #2

    Hi Anguye,

    We have opened a ticket and are going to investigate this ASAP.

    Thanks, Declan


    Declan_ginty | 2023-03-07 10:44:13 UTC | #3

    Hi Anguye,

    The workforce management api class in Python is actually named WorkforceManagementApi with no underscore. So you would write:

    api_instance = PureCloudPlatformClientV2.WorkforceManagementApi()

    Theres seems to be some differences between class names in the api explorer and the SDK we will look in to, thanks for bring this to our attention.

    Regards, Declan


    anguye10 | 2023-03-07 14:03:18 UTC | #4

    Thank you,

    That worked but now I am getting this error: NameError: name 'include_only_published' is not defined

    It appears to be from this line of code: api_response = api_instance.get_workforcemanagement_businessunit_week_schedules(business_unit_id, week_id, include_only_published=include_only_published, expand=expand)


    brian.trezise | 2023-03-07 14:31:47 UTC | #5

    I think I can speak to that - under the hood, the api you're communicating with is written in Java with java naming conventions. So I believe it should be includeOnlyPublished=include_only_published(camel case). We'll be checking into the doc here to make it better.


    anguye10 | 2023-03-07 22:02:12 UTC | #6

    That did it. Thank you for your helps.


    system | 2023-04-07 22:02:58 UTC | #7

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