Genesys Cloud - Developer Community!

 View Only

Sign Up

  • 1.  Missing methods in Java API

    Posted 22 days ago
    Edited by Wolfgang Liebich 22 days ago

    Hello,

    I looked right now into the current platform API (via API explorer) and found a strange problem in [GET /api/v2/workforcemanagement/businessunits/{businessUnitId}/managementunits](https://developer.genesys.cloud/devapps/api-explorer#get-api-v2-workforcemanagement-businessunits--businessUnitId--managementunits). This API does not allow me to set page number or page size, but the response is a paged response having both page number and total page sizes inside.

    If the response has more than 1 page - how am I supposed to fetch the next pages?

    EDIT: The title says "Java PSDK", b/c this is where I found the problem - but I could see it in the API explorer, too.

    Thanks in advance,

    Wolfgang Liebich


    #PlatformAPI
    #PlatformSDK

    ------------------------------
    Wolfgang
    ------------------------------



  • 2.  RE: Missing methods in Java API

    Posted 22 days ago

    Hi Wolfgang,

    I came across an older Developer Community discussion reporting a similar issue with the exact same endpoint. The poster mentioned that pageSize and pageNumber were being ignored, and Genesys Developer Engagement recommended opening a Care case. Unfortunately, I couldn't find a confirmed resolution in that thread.

    https://community.genesys.com/discussion/apiv2workforcemanagementbusinessunitsbusinessunitidmanagementunits-returns-wrong-paging-uri-for-nexturiselfuri

    Interestingly, in another discussion, Genesys confirmed that the general Management Units endpoint retains pagination metadata for historical compatibility but returns all authorized management units in a single response:

    https://community.genesys.com/discussion/workforce-management-managementunit-pagination

    I'm not sure whether the same behaviour applies to the business-unit-specific endpoint. Hopefully, someone from the WEM community can provide further clarification.

    Hope this helps!



    ------------------------------
    Phaneendra
    Technical Solutions Consultant
    ------------------------------



  • 3.  RE: Missing methods in Java API

    Posted 21 days ago

    Hi @Wolfgang Liebich, I checked the public OpenAPI spec, and it points to this being intentional rather than a missing SDK method.

    GET /api/v2/workforcemanagement/businessunits/{businessUnitId}/managementunits only takes feature and divisionId as query parameters. Its description is "Get all authorized management units in the business unit". The older GET /api/v2/workforcemanagement/managementunits still lists pageSize and pageNumber, but both are described as "Deprecated, paging is not supported".

    The response model, ManagementUnitListing, carries the usual pageSize, pageNumber, pageCount and nextUri fields because it uses the standard listing shape. As far as I can tell from the spec, those fields don't mean the result is paged: the call is meant to return every authorized management unit in one response. So the Java method has no paging arguments because the API has none.

    I'd confirm that with a test against a business unit that has many MUs: check that entities.size() matches the count you see in the UI and that nextUri is null. If you ever get a nextUri, that would be a bug worth a Care case.



    ------------------------------
    Sebastian
    Ingeniero de Proyecto
    ------------------------------



  • 4.  RE: Missing methods in Java API

    Posted 13 days ago

    Hi,

    OK, thanks - this then settles the issue. I was just wondering. As an aside, the return value format of various query methods is not that consistent - we have paging and entities, for search results we have paging, but results instead of entities, other queries use a cursor - this variety makes it hard to have somewhat uniform low-level methods handling, for example, fetching all pages while observing rate limits. A more homogenous interface would be helpful here.

    Thanks for the information,

    Wolfgang Liebich



    ------------------------------
    Wolfgang
    ------------------------------



  • 5.  RE: Missing methods in Java API

    Posted 6 days ago

    Agreed, Wolfgang, it's one of the first things we wrap in any integration. What has worked for us is a small pager with three strategies picked per endpoint: entities + nextUri/pageCount for the standard listings, results + pageNumber/total for the search endpoints, and cursor for analytics job results and the other cursor-based queries (the public OpenAPI spec has over 130 operations with a cursor or after parameter, so it's not a corner case). For rate limits, the Java SDK can handle the backoff itself if you build the ApiClient with a RetryConfiguration (setMaxRetryTimeSec, setRetryMax). It's off by default, so it's easy to miss.



    ------------------------------
    Sebastian
    Ingeniero de Proyecto
    ------------------------------



  • 6.  RE: Missing methods in Java API

    Posted 6 days ago

    Hi,

    I saw similar results, and used a similar abstraction. Unfortunately, the JavaScript API does not natively support rate limits, we have to do it by ourselves.

    Also, a universal paging code which also handles rate limits can be tricky.

    Regards,

    Wolfgang Liebich



    ------------------------------
    Wolfgang
    ------------------------------



  • 7.  RE: Missing methods in Java API

    Posted 5 days ago

    Right, the JavaScript SDK doesn't have an equivalent of the Java RetryConfiguration, at least I couldn't find one in the current README. What it does let you do is replace the HTTP client: setHttpClient() takes a class that extends the SDK's AbstractHttpClient and implements request(options). We use that as the single place for throttling: wrap the axios call, and on a 429 wait for the Retry-After header and retry, with a cap on attempts. The paging code then never has to think about rate limits, which keeps the "universal pager" a lot simpler.



    ------------------------------
    Sebastian
    Ingeniero de Proyecto
    ------------------------------



  • 8.  RE: Missing methods in Java API

    Posted 5 days ago

    Hm, interesting, we also have a wrapper, but this starts out already at a higher layer - and our components only use that higher layer, so the knowledge of the rate limits is concentrated in 1 component.

    Regards,

    Wolfgang Liebich



    ------------------------------
    Wolfgang
    ------------------------------