Yaro | 2023-10-11 07:08:55 UTC | #1
Hi team. I am trying to access GET API, using following Python Code:
import PureCloudPlatformClientV2
from PureCloudPlatformClientV2.rest import ApiException from pprint import pprint
region = PureCloudPlatformClientV2.PureCloudRegionHosts.euwest2 PureCloudPlatformClientV2.configuration.host = region.getapihost() apiclient = PureCloudPlatformClientV2.apiclient.ApiClient().getclientcredentialstoken('****', '********')
RoutingApi = PureCloudPlatformClientV2.AuthorizationApi(apiclient)
create an instance of the API class
apiinstance = PureCloudPlatformClientV2.RoutingApi(); pagenumber = 1 pagesize = 25 sortorder = 'asc' name = 'nameexample' id = ['idexample'] divisionid = ['divisionidexample'] peerid = ['peeridexample'] has_peer = True
try:
Get list of queues.
apiresponse = apiinstance.getroutingqueues(pagenumber=pagenumber, pagesize=pagesize, sortorder=sortorder, name=name, id=id, divisionid=divisionid, peerid=peerid, haspeer=haspeer) pprint(apiresponse) except ApiException as e: print("Exception when calling RoutingApi->getrouting_queues: %s\n" % e)
it keeps giving me an error
Exception when calling RoutingApi->getroutingqueues: (401) Reason: Unauthorized HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Content-Length': '201', 'Connection': 'keep-alive', 'Date': 'Wed, 11 Oct 2023 06:57:12 GMT', 'ININ-Correlation-Id': '40f27941-f5f4-4082-84d3-6f2978b2782d', 'Strict-Transport-Security': 'max-age=600; includeSubDomains', 'Cache-Control': 'no-cache, no-store, must-revalidate', 'X-Cache': 'Error from cloudfront', 'Via': '1.1 828a61ebc3af4e0465a5577a4c08af7a.cloudfront.net (CloudFront)', 'X-Amz-Cf-Pop': 'ARN54-C1', 'X-Amz-Cf-Id': 'WpHpy7oJas9kYXrOqPO4Ahxsy5KWRbL9rxSyFhoFMgBaGGfuu12g=='}) HTTP response body: {"message":"No authentication bearer token specified in authorization header.","code":"authentication.required","status":401,"contextId":"40f27941-f5f4-4082-84d3-6f2978b2782d","details":[],"errors":[]} START RequestId: 8734dfae-ecbe-42d8-b159-0aa2261b9d83 Version: $LATEST [ERROR] Runtime.HandlerNotFound: Handler 'lambdahandler' missing on module 'lambdafunction' Traceback (most recent call last):END RequestId: 8734dfae-ecbe-42d8-b159-0aa2261b9d83
Please suggest. Thank you.
Hemanth | 2023-10-11 07:57:56 UTC | #2
Hi
Are you setting the RoutingApi correct ?
Two pieces of code you can check this
PureCloudPlatformClientV2.AuthorizationApi(apiclient). --> This is correct way to get Api reference but here you used AuthorizationApi so you would get authApi instance not routingApi
apiinstance = PureCloudPlatformClientV2.RoutingApi(); You are not sending the apiclient argument for this. Did you try apiinstance = PureCloudPlatformClientV2.RoutingApi(apiclient) ?
system | 2023-11-11 07:58:18 UTC | #3
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: 22468