Legacy Dev Forum Posts

 View Only

Sign Up

Changing presence from IC REST tools

  • 1.  Changing presence from IC REST tools

    Posted 06-05-2025 18:13

    george.ganahl | 2018-08-15 20:33:39 UTC | #1

    I'm trying to use the v2 API to PATCH user presence from a handler in Interaction Center, using the REST tools.

    I am able to get a Bearer Token from PureCloud using Client Credentials.

    For v2, my REST HTTP Request in IC logs:

    i3inet::impl::ClientTransaction::resume_transaction() : Client policy selected <TLS/[::]:0/api.mypurecloud.com:443/transactionCount=0> to transmit PATCH /api/v2/users/e11fef61-1efa-4388-97a5-aeab7ccc0131/presences/PURECLOUD HTTP/1.1

    It then gets a response:

    RESTHTTPRequest() : Response received. finaluri: <https://api.mypurecloud.com/api/v2/users/e11fef61-1efa-4388-97a5-aeab7ccc0131/presences/PURECLOUD>, statuscode: 400, reason: Bad Request, bstrheaders: Content-Type: application/json Content-Length: 198 Connection: keep-alive Date: Wed, 15 Aug 2018 18:00:01 GMT ININ-Correlation-Id: d04bd0be-3245-4adb-a260-cc3b31698831 Cache-Control: no-cache, no-store, must-revalidate Pragma: no-cache Expires: 0 X-Cache: Error from cloudfront Via: 1.1 5a501e9cc6aa44f4c87ff790902a3af9.cloudfront.net (CloudFront) X-Amz-Cf-Id: W1UTdDSmjZXkxudw-pfVcrsVGf3tmeWcltiVHjdfa8uVHZVp_SAAw==

    [Context Attribute 'Thread Name']: IP-Handler [Context Attribute 'IP Context Id']: 8723

    I haven't tried looking in Sumo yet...any ideas on what I might be missing? Or, is it that the Client Credentials OAuth doesn't work for the v2 request?


    anon28066628 | 2018-08-15 20:13:33 UTC | #2

    Hi George, I'm able to patch users' presence using Client Credentials grant. The below Postman call had no issues.

    curl -X PATCH \ https://api.mypurecloud.com/api/v2/users/289a802d-d6d5-4bfa-bbef-b80f60b0bc85/presences/PURECLOUD \ -H 'Authorization: bearer {{CLIENTCREDENTIALSTOKEN}}' \ -H 'Cache-Control: no-cache' \ -H 'Content-Type: application/json' \ -H 'Postman-Token: cc67f9bf-94ca-4158-9a05-335235a26f05' \ -d '{ "source": "PURECLOUD", "primary": true, "presenceDefinition": { "id": "3fd96123-badb-4f69-bc03-1b1ccc6d8014", "systemPresence": "Meal" } }'


    tim.smith | 2018-08-15 20:33:21 UTC | #4

    Your request body is malformed in some way. The API is throwing an error internally trying to deserialize the presence definition.


    george.ganahl | 2018-08-15 20:44:17 UTC | #5

    Ok.

    I think it is in the JSON Builder tool. It is missing a set of braces, and creates:

    { "primary":true, "presenceDefinition":"e08eaf1b-ee47-4fa9-a231-1200e284798f" }


    tim.smith | 2018-08-15 20:52:28 UTC | #6

    Yep, that body would cause that error.


    george.ganahl | 2018-08-15 20:52:41 UTC | #7

    I manually re-shaped it to:

    { "presenceDefinition": { "id": "e08eaf1b-ee47-4fa9-a231-1200e284798f" } }

    and the handler worked. I'll just have to hard code, and avoid the JSON


    system | 2018-09-15 20:52:44 UTC | #8

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