API call is not working for Edge List

Hello ,

var request = require('request');

function handleTokenCallback(body){
var options = {
url: 'Calling Roles API here**',
headers: {
'Authorization': body.token_type + " " + body.access_token
//console.log(body.token_type,body.access_token)
}
};

request(options, function (error, response, body) {
    if (!error && response.statusCode == 200) {
        //console.log(JSON.stringify(JSON.parse(body), null, 2));
        console.log('printing the JSON')
    }else{
        console.log('Printing Error: '+ error)
        console.log(body.token_type + ' ' + body.access_token)
    }
});

}

secret = process.env.purecloud_secret;
id = process.env.purecloud_client_id;


The above code working fine if I pass this Roles URL -

But, I dont get the JSON when I use this URL - "https://api.mypurecloud.de/api/v2/telephony/providers/edges"

Can you please help?

Regards,
Suresh

Works well for https://api.mypurecloud.de/api/v2/authorization/roles

doesnt work for https://api.mypurecloud.de/api/v2/telephony/providers/edges

Suresh, are you receiving an error when you call /api/v2/telephony/providers/edges? What do you mean by "doesn't work"?

Thanks for the reply, Becky. I am getting the response now for the API call. Basically I had to give permission to the application created in Integrations->OAuth.

I am getting the reponse when I call for Edges details. Is it possible to send one more API calls to get the trunk list in the code mentioned?

Hi Suresh,

Here is the API resource that you can call to fetch the list of available trunks for a given Edge: https://developer.mypurecloud.com/api/rest/v2/telephonyprovidersedge/#get-api-v2-telephony-providers-edges--edgeId--trunks.

--Becky

Thanks Becky. I was getting the response. But suddenly, i am getting the below error.
{ Error: unable to get local issuer certificate
at TLSSocket.onConnectSecure (_tls_wrap.js:1058:34)
at TLSSocket.emit (events.js:198:13)
at TLSSocket._finishInit (_tls_wrap.js:636:8) code: 'UNABLE_TO_GET_ISSUER_CERT_LOCALLY' }
Can you please advise.

It sounds like your company network is using a cert in its proxy that your code doesn't trust: nodejs/node#3742.

Possible solution: https://stackoverflow.com/questions/46968937/nodejs-request-post-not-working-for-https-website/46968984#46968984

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