Workforce_ManagementApi

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.access_token = 'your_access_token'
    # or use get_client_credentials_token(...), get_saml2bearer_token(...) or get_code_authorization_token(...)

    # create an instance of the API class
    api_instance = PureCloudPlatformClientV2.Workforce_ManagementApi()
    business_unit_id = 'business_unit_id_example' # str | The ID of the business unit
    week_id = 'week_id_example' # str | First day of schedule week in yyyy-MM-dd format, or 'recent' (without quotes) to get recent schedules
    include_only_published = True # bool | includeOnlyPublished (optional)
    expand = 'expand_example' # str | expand (optional)

    try:
        # Get the list of week schedules for the specified week
        api_response = api_instance.get_workforcemanagement_businessunit_week_schedules(business_unit_id, week_id, include_only_published=include_only_published, expand=expand)
        pprint(api_response)
    except ApiException as e:
        print("Exception when calling GetWorkforcemanagementBusinessunitWeekSchedulesRequest->get_workforcemanagement_businessunit_week_schedules: %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,

Hi Anguye,

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

Thanks,
Declan

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

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)

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.

That did it. Thank you for your helps.

1 Like

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