Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses and challenges
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Calculator

0

200
Views
Why does urlfetch() give me "Service invoked too many times for one day" in this context using GAS to get API data?

I've been trying to get all candidates from Catsone into a Google Sheet and although the code is apparently according to their API instruction, I'm getting the above mentioned error and I'm not sure where to look for the issue.

Here's the code I'm running:

const API_KEY = "XXXXXXXXXXXXXXXXXXXXXXXX";

function getallcandidates() {
  const url = 'https://api.catsone.com/v3/candidates';
  const params = {
    'muteHttpExceptions': true,
    'method': 'GET',
    'headers': {
      'Content-Type': 'application/json',
      'Authorization': 'Token' + API_KEY
    }
  };

  const response = UrlFetchApp.fetch(url, params);
  const data = response.getContentText();
  const json = JSON.parse(data);
  Logger.log('Data: ' + json)
}

These are their instructions for authentication: https://docs.catsone.com/api/v3/#authentication

This is what successfully I got whe I tried calling it from Postman:

var myHeaders = new Headers();
myHeaders.append("Authorization", "Token XXXXXXXXXXXXXXXXXXXX");

var requestOptions = {
  method: 'GET',
  headers: myHeaders,
  redirect: 'follow'
};

fetch("https://api.catsone.com/v3/candidates", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Appreciate any help.

7 months ago · Juan Pablo Isaza
1 answers
Answer question

0

When I saw your added Javascript and your Google Apps Script, if the value of const API_KEY = "XXXXXXXXXXXXXXXXXXXXXXXX"; has no space at the top character, how about the following modification?

Modified script:

From:

'Authorization': 'Token' + API_KEY

To:

'Authorization': 'Token ' + API_KEY
  • From your additional Javascript, 'Token' is modified to 'Token '.
7 months ago · Juan Pablo Isaza Report
Answer question
Find remote jobs