Scripts - Get User Extension - Integration/ Data Action

Hello Everyone,

I am integrating Web CRM application with PureCloud.
Each user in Web CRM has ID, and I need this ID in the script.
Each user in PureCloud has an extension same as his Web CRM id.

My question, how can I get/show this extension number inside script?

One I was thinking of is to create action that calls /api/v2/users/me, so each user, when the script is opened for her/him, then her/his ID should be at least presented. Unfortunately, the action for /api/v2/users/me is not working with me:

REST call for action execute failed. Message:Request to backend service failed. Response from web service: {"status":400,"code":"not.a.user","message":"This request requires a user context. Client credentials cannot be used for requests to this resource."} [30a5dfeb-c421-4f84-b16d-XXXXXXXXXXXX]

{
  "status": 400,
  "code": "bad.request",
  "message": "The request could not be understood by the server due to malformed syntax.",
  "messageParams": {},
  "contextId": "1b597966-0c4f-43af-812e-990024ddbe25",
  "details": [],
  "errors": [
    {
      "status": 400,
      "code": "BAD_REQUEST",
      "message": "REST call for action execute failed. Message:Request to backend service failed.  Response from web service: {\"status\":400,\"code\":\"not.a.user\",\"message\":\"This request requires a user context. Client credentials cannot be used for requests to this resource.\"} [1b597966-0c4f-43af-812e-990024ddbe25]",
      "messageParams": {},
      "details": [],
      "errors": []
    }
  ]
}

Best Regards,
Ali

That error message is correct. You can't use APIs that require a user context with client credentials.

There's a script variable that has the agent ID. Use that as an input to your data action to look up the user.

1 Like

Thank you, Tim.

I used this API /api/v2/users/{userId} in which userId is Scripter.Agent ID, as Tim suggested.

Best Regards,
Ali

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