Legacy Dev Forum Posts

 View Only

Sign Up

Notification service subscribe

  • 1.  Notification service subscribe

    Posted 06-05-2025 18:20

    Alex_Kopt | 2021-08-26 12:39:40 UTC | #1

    Hi everyone,

    I have OAuth client application and I want to subscribe it to notification topic and get data from WebSocket. v2.users.{userId}.workforcemanagement.historicaladherencequery

    But I cant do it, because my OAuth client application has not userId.

    Could someone please help me? What should I do to get this data?

    Thank and best regards, Alex


    tim.smith | 2021-08-26 14:25:45 UTC | #2

    Hello, here's a thread about this: https://developer.genesys.cloud/forum/t/problems-getting-historical-adherence/6622/8?u=tim.smith

    TLDR; use the requesting user's ID when using a user-based grant and use your oauth client ID when using client credentials.


    Alex_Kopt | 2021-08-26 14:46:07 UTC | #3

    Thanks for quick answer.

    I tried it before creating thread, but, unfortunately, it didn`t work. Get 404 error.


    tim.smith | 2021-08-26 14:58:45 UTC | #4

    Can you be more specific about exactly what you tried? Can you share details of the request and response?


    Alex_Kopt | 2021-08-26 15:39:50 UTC | #5

    Firstly, I checked that I have necessary topic in list of topics https://api.mypurecloud.com/api/v2/notifications/availabletopics

    Secondly, I created WebSocket channel via POST https://{API URL by region}/api/v2/notifications/channels And got connectUri and id from that

    Thirdly, I POST /api/v2/notifications/channels/{channelId}/subscriptions Where channelId == id of channel from previous step And put in json body {"id":"v2.users.{client_id}.workforcemanagement.historicaladherencequery"} with


    Alex_Kopt | 2021-08-26 15:41:07 UTC | #6

    With client id from my OAuth Client Grant Credentials


    Alex_Kopt | 2021-08-26 15:58:38 UTC | #7

    And I got 404 error with "The request could not be understood by the server due to malformed syntax"


    brian.trezise | 2021-08-26 16:07:11 UTC | #8

    From the documentation on the subscription route:

    POST /api/v2/notifications/channels/{channelId}/subscriptions

    The request body is required to be an array of objects with IDs, like so:

    [
      {
        "id": ""
      }
    ]

    I personally find the request body schema easier to follow if you click the "Json" tab rather than looking at the "schema" tab, I hope this helps


    Alex_Kopt | 2021-08-26 16:26:11 UTC | #9

    Oh my god, it finally subscribed. I thought I didn`t need to use [ ] for one value.

    Remains to understand why I do not receive messages in WebSocket messages after to api/v2/workforcemanagement/managementunits/{id}/historicaladherencequery except WSMessage(type=<WSMsgType.TEXT: 1>, data='{"topicName": "channel.metadata", "eventBody": {"message": "WebSocket Heartbeat"}}', extra='')


    brian.trezise | 2021-08-26 17:10:53 UTC | #10

    Can you provide a correlationId for one of the requests to /api/v2/workforcemanagement/managementunits/{id}/historicaladherencequery?


    Alex_Kopt | 2021-08-26 16:57:09 UTC | #11

    Finally, I did it with you help, guys

    Thanks a lot!

    The root of issue was that every access token has own channels and topics, so i did it in different clients and hoped message from WS.

    It's very nice that you helped me so quickly, you are cool

    @tim.smith @brian.trezise


    brian.trezise | 2021-08-26 17:08:38 UTC | #12

    Happy to be of assistance and I'm glad you were able to get it working!


    system | 2021-09-26 17:09:12 UTC | #13

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