News & Announcements User Community Developer Community

Welcome to the RingCentral Community

Please note the community is currently under maintenance and is read-only.

Search
Make sure to review our Terms of Use and Community Guidelines.
  Please note the community is currently under maintenance and is read-only.
Home » Developers
Why am I getting 403 Forbidden errors using the Compliance API when I run reports?
Tags: error
Aug 22, 2019 at 9:17pm   •   4 replies  •  0 likes
justin-nguyen

I use Compliance API daily to run reports. But today and yesterday I get the error "403 Forbidden", so I can't make report. Please check and let me now this issue.

4 Answers
answered on Feb 10, 2020 at 11:31pm  

Thanks, It work when I run your NodeJS code. But my application with .net SDK still error =))


 0
answered on Feb 10, 2020 at 12:17pm  

I run my test code and it works well today. Can you try this Node JS code on your machine, just make sure you have installed the RingCentral JS SDK and replace the app and user login credentials

var rcsdk = new SDK({
      server: RINGCENTRAL_SERVER,
      appKey: RINGCENTRAL_CLIENTID,
      appSecret: RINGCENTRAL_CLIENTSECRET
  });
var platform = rcsdk.platform();
platform.login({
      username: RINGCENTRAL_USERNAME,
      password: RINGCENTRAL_PASSWORD,
      extension: RINGCENTRAL_EXTENSION
      })
      .then(function(resp) {
          create_glip_compliance_export_task()
      });
 
function create_glip_compliance_export_task(){
    console.log("Create export task.")
    var endpoint = "/restapi/v1.0/glip/data-export"
    var params = {
        timeFrom: "2019-08-01T00:00:00.000Z",
        timeTo: "2020-01-15T23:59:59.999Z",
      }
    platform.post(endpoint, params)
      .then(function(resp){
          var json = resp.json()
          console.log(JSON.stringify(json))
          get_glip_compliance_export_task(json.id)
      })
      .catch(function(e){
          console.log(e)
      })
}
 
function get_glip_compliance_export_task(taskId){
    console.log("Check export task status ...")
    var endpoint = "/restapi/v1.0/glip/data-export/" + taskId
    platform.get(endpoint)
      .then(function(resp){
          var json = resp.json()
          if (json.status == "Completed"){
            console.log(JSON.stringify(json))
              for (var i=0; i<json.datasets.length; i++){
                var fileName = "glip-export-reports/" + json.creationTime + "_" + i + ".zip"
                console.log(json.datasets[i].uri)
                get_glip_report_archived_content(json.datasets[i].uri, fileName)
              }
          }else if (json.status == "Accepted" || json.status == "InProgress") {
              setTimeout(function(){
                get_glip_compliance_export_task(taskId)
              }, 5000);
          }else
              console.log(json.status)
      })
      .catch(function(e){
          console.log(e)
      })
}
 
function get_glip_report_archived_content(contentUri, fileName){
    var uri = platform.createUrl(contentUri, {addToken: true});
    download(uri, fileName, function(){
        console.log("Save report zip file to the local machine. " + fileName)
    })
}
 
const download = function(uri, dest, cb) {
    var file = fs.createWriteStream(dest);
    var request = https.get(uri, function(response) {
        response.pipe(file);
        file.on('finish', function() {
            file.close(cb);
        });
    });
}



 0
answered on Feb 10, 2020 at 9:38am  

I run my test code and it works well today. Can you try this Node JS code on your machine, just make sure you have installed the RingCentral JS SDK and replace the app and user login credentials

var rcsdk = new SDK({
      server: RINGCENTRAL_SERVER,
      appKey: RINGCENTRAL_CLIENTID,
      appSecret: RINGCENTRAL_CLIENTSECRET
  });
var platform = rcsdk.platform();
platform.login({
      username: RINGCENTRAL_USERNAME,
      password: RINGCENTRAL_PASSWORD,
      extension: RINGCENTRAL_EXTENSION
      })
      .then(function(resp) {
          create_glip_compliance_export_task()
      });

function create_glip_compliance_export_task(){
    console.log("Create export task.")
    var endpoint = "/restapi/v1.0/glip/data-export"
    var params = {
        timeFrom: "2019-08-01T00:00:00.000Z",
        timeTo: "2020-01-15T23:59:59.999Z",
      }
    platform.post(endpoint, params)
      .then(function(resp){
          var json = resp.json()
          console.log(JSON.stringify(json))
          get_glip_compliance_export_task(json.id)
      })
      .catch(function(e){
          console.log(e)
      })
}

function get_glip_compliance_export_task(taskId){
    console.log("Check export task status ...")
    var endpoint = "/restapi/v1.0/glip/data-export/" + taskId
    platform.get(endpoint)
      .then(function(resp){
          var json = resp.json()
          if (json.status == "Completed"){
            console.log(JSON.stringify(json))
              for (var i=0; i<json.datasets.length; i++){
                var fileName = "glip-export-reports/" + json.creationTime + "_" + i + ".zip"
                console.log(json.datasets[i].uri)
                get_glip_report_archived_content(json.datasets[i].uri, fileName)
              }
          }else if (json.status == "Accepted" || json.status == "InProgress") {
              setTimeout(function(){
                get_glip_compliance_export_task(taskId)
              }, 5000);
          }else
              console.log(json.status)
      })
      .catch(function(e){
          console.log(e)
      })
}

function get_glip_report_archived_content(contentUri, fileName){
    var uri = platform.createUrl(contentUri, {addToken: true});
    download(uri, fileName, function(){
        console.log("Save report zip file to the local machine. " + fileName)
    })
}

const download = function(uri, dest, cb) {
    var file = fs.createWriteStream(dest);
    var request = https.get(uri, function(response) {
        response.pipe(file);
        file.on('finish', function() {
            file.close(cb);
        });
    });
}



 0
answered on Feb 9, 2020 at 5:42pm  

Compliance Api don't work. I get taskId successfull, Then I using taskId to get report.zip file but taskId return reult is null. Please check, it still work very good in 2019.


 0
answered on Aug 23, 2019 at 12:27am  

403 means forbidden permission which means you are not authorized or allowed. This happens when you get with wrong credentials like client id or client secret or wrong phone number or extension etc or particular permission is missing.

Make sure if anything changed. Check with the developer support team by submitting a help ticket and providing them full details of your API and environment.


 0



A new Community is coming to RingCentral!

Posts are currently read-only as we transition into our new platform.

We thank you for your patience
during this downtime.

Try Workflow Builder

Did you know you can easily automate tasks like responding to SMS, team messages, and more? Plus it's included with RingCentral Video and RingEX plans!

Try RingCentral Workflow Builder

PRODUCTS
RingEX
Message
Video
Phone
OPEN ECOSYSTEM
Developer Platform
APIs
Integrated Apps
App Gallery
Developer support
Games and rewards

RESOURCES
Resource center
Blog
Product Releases
Accessibility
QUICK LINKS
App Download
RingCentral App login
Admin Portal Login
Contact Sales
© 1999-2024 RingCentral, Inc. All rights reserved. Legal Privacy Notice Site Map Contact Us