Johnson_Lu1 | 2018-10-01 09:53:24 UTC | #1
Hi,
I would like to seek someone help on this issue 403 error when I build custom PureCloud Data Action using API /api/v2/telephony/providers/edges/trunks/{trunkId}/metrics. However, when I use developer Tool - API explorer, I can get the output correctly.
For your info, I am in Australia region.
Below is the error.
{ "status": 403, "code": "not.authorized", "message": "You are not authorized to perform the requested action.", "messageParams": {}, "contextId": "1b7d768f-06c4-498e-bbae-e00f00b26f30", "details": [], "errors": [ { "status": 403, "code": "NOT_AUTHORIZED", "message": "REST call for action execute failed. Message:Request to backend service failed. Response from web service: {\"status\":403,\"code\":\"not.authorized\",\"message\":\"You are not authorized to perform the requested action.\"} [1b7d768f-06c4-498e-bbae-e00f00b26f30]", "messageParams": {}, "details": [], "errors": [] } ] }
Here are my custom Data Action:
Input Contract: { "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "required": [ "TrunkID" ], "properties": { "TrunkID": { "type": "string", "title": "Trunk ID", "description": "Requires TrunkID" } } }
Output Contract
{ "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "properties": { "TotalInboundCalls": { "type": "integer", "title": "Total Inbound Calls", "description": "Total inbound calls" }, "TotalOutboundCalls": { "type": "integer", "title": "Total Outbound Calls", "description": "Total outbound calls" } } }
Request { "requestUrlTemplate": "/api/v2/telephony/providers/edges/trunks/${input.TrunkID}/metrics", "requestType": "GET", "headers": {}, "requestTemplate": "${input.rawRequest}" }
Response { "translationMap": { "TotalInboundCalls": "$.calls.inboundCallCount", "TotalOutboundCalls": "$.calls.outboundCallCount" }, "translationMapDefaults": {}, "successTemplate": "{\n \"Total Inbound\": ${TotalInboundCalls}\n,\"Total Outbound\": ${TotalOutbountCalls}}" }
Thanks & Regards,
Johnson
Jason_Mathison | 2018-10-01 14:12:32 UTC | #2
Have you verified that your client credentials have the permission required for this endpoint? The API browser indicates that this is required:
Johnson_Lu1 | 2018-10-02 01:20:14 UTC | #3
Hi, Jason,
I don't understand this.
I thought the PureCloud Data Actions do not required any client credential or token. What I would like to archive is the main IVR will call this Data Actions to get the total calls, and alert caller by play a voice prompt if total calls exceeded 70, says.
May you advice any way to bypass it or any way to hardcode the credential.
Regards,
Johnson
Jason_Mathison | 2018-10-02 01:49:26 UTC | #4
Hi Johnson,
The PureCloud data action needs to have a client credential created for it. Starting from the getting started page: https://help.mypurecloud.com/articles/about-purecloud-data-actions-integration/
you need to follow the directions for "Add a PureCloud OAuth client": https://help.mypurecloud.com/articles/add-purecloud-oauth-client-purecloud-data-actions-integration/
Specifically you need to give that client credential a role that includes the telephony:plugin:all permission.
Once you have created the client credential you will need to update the PureCloud Data Action integration to use the ClientID and Secret. If you already have created a client credential, then you only need to update the role to include the required permission.
--Jason
Johnson_Lu1 | 2018-10-02 02:10:06 UTC | #5
Thanks, Jason,
I works now without the error 103.
May I ask one more question? For the Response,
Response { "translationMap": { "TotalInboundCalls": "$.calls.inboundCallCount", "TotalOutboundCalls": "$.calls.outboundCallCount" }, "translationMapDefaults": {}, "successTemplate": "{\n "Total Inbound": ${TotalInboundCalls}\n,"Total Outbound": ${TotalOutbountCalls}}" }
Look like I have some syntax error, I can't get the result correctly. What I need is the Data Actions return the 2 values (total inbound calls & total outbound calls).
Regards,
Johnson
Jason_Mathison | 2018-10-02 02:29:53 UTC | #6
Hi Johnson,
Please include an example of the execution output of a test (this is what the metrics API is returning) as well as whatever error you are seeing as well as a correlation ID of a failed test.
--Jason
Johnson_Lu1 | 2018-10-02 04:49:53 UTC | #7
Johnson_Lu1, post:5, topic:3657
"successTemplate": "{\n "Total Inbound": ${TotalInboundCalls}\n,"Total Outbound": ${TotalOutbountCalls}}"
Hi, Jason, I changed the syntax to "successTemplate": "{\n \"Total Inbound\": \"${TotalInboundCalls}\"\n,\"Total Outbound\": \"${TotalOutbountCalls}\"\"}"
Then, I got below.
However, if I remove the portion after , I will not get error, but the result is blank. "successTemplate": "{\n \"Total Inbound\": \"${TotalInboundCalls}\"\n}"
I will get.
 |
 |
Regards, Johnson
Johnson_Lu1 | 2018-10-02 10:13:54 UTC | #8
Hi, Jason,
I found my syntax error. I have a typo error - ${TotalOutbountCalls} -> wrong
${TotalOutboundCalls} -> correct.
However, is so funny, Json showed me I have the total inbound & outbound call, but it does not able to display it as my output. Any idea why?
Regards,
Johnson
Jason_Mathison | 2018-10-02 14:02:22 UTC | #9
Your output schema is indicates that you should be setting "TotalInboundCalls" and "TotalOutboundCalls"
but your success template is actually setting "Total Inbound"
One way to make it easier to find errors like this is to make the output schema values required. It is easy to not realize that you have a name mismatch when test mode doesn't obviously fail.
Johnson_Lu1 | 2018-10-03 01:03:36 UTC | #10
Jason_Mathison, post:9, topic:3657
make the output schema values required
Thanks, Jason,
It resolved.
However, may i know how to make the output schema values required?
Thanks & regards,
Johnson
Jason_Mathison | 2018-10-03 12:08:08 UTC | #11
You have an example of a required field in your input contract:
"required": [ "TrunkID" ],
You can add the same sort of thing to your output contract, like:
{ "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "required": [ "TotalInboundCalls", "TotalOutboundCalls" ], "properties": { "TotalInboundCalls": { "type": "integer", "title": "Total Inbound Calls", "description": "Total inbound calls" }, "TotalOutboundCalls": { "type": "integer", "title": "Total Outbound Calls", "description": "Total outbound calls" } } }
One other note if you have issues with an action in the future, you can export your action into a .json file and post that file instead of having to copy and paste all of the different parts of the action configuration. Note that you would want to remove anything sensitive in your action configuration.
system | 2018-11-03 12:06:35 UTC | #12
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: 3657