Zoho Recruit API and Google Sheets OAuth2 process

Zoho Recruit API and Google Sheets OAuth2 process

Hello fellow ZR API user,

I need to use Zoho Recruit API together with Google (because our team is operating within Google Sheets already).

I use this library to support OAuth2 for Zoho in Google Sheets: 
(looks amazing and seems to work well for others)

Interesting:
* Works really well for the Zoho CRM API for me
* Does not work for Zoho Recruit API for me (always get a 400 error)

My questions:
* Do I use wrong scope or code? Does anything stand out?
* Are there other / better libraries / code I can use?

Thank you!

Before this suggestion comes up:
I contacted Zoho Recruit Support 2 weeks ago with multiple follow-ups without any answer.
This is why I am turning to the community (I would have hoped for Zoho to help me out here)

----
Google App Script Code

/**
 * This sample demonstrates how to connect to the Zoho CRM API.
 */

var CLIENT_ID = '1000.xxxxxxxxxxxxxxxxxxxx';
var CLIENT_SECRET = 'xxxxxxxxxxxxxx';

function writeToSheet(content) {
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  sheet.appendRow([content]); // Write the entire content to the first cell of a new row
}
function saveToDrive(content) {
  var fileName = 'API Error Response ' + new Date().toISOString();
  DriveApp.createFile(fileName, content, MimeType.PLAIN_TEXT);
}

/**
 * Authorizes and makes a request to the Zoho CRM API.
 */
function run() {
  var service = getService_();
  if (service.hasAccess()) {
    // Retrieve the API server from the token.
    var apiServer = service.getToken().api_domain;
    // var url = apiServer + '/crm/v2/org';  // I leave them in here for troubleshooting
    var url = apiServer + '/recruit/v2/org';
    var response = UrlFetchApp.fetch(url, {
      method: 'get',
      headers: {
        'Authorization': 'Bearer ' + service.getAccessToken(),
        'Content-Type': 'application/json'
      },
      muteHttpExceptions: true
    });
    
    // writeToSheet(response.getContentText());
    // saveToDrive(response.getContentText());
    
    // Log the status code and headers to understand the response better
    Logger.log(response.getResponseCode());
    Logger.log(response.getHeaders());

    // Log the raw content of the response
    Logger.log(response.getContentText());
    
    
    // Attempt to parse the response as JSON, with error handling
    var result;
    try {
      result = JSON.parse(response.getContentText());
    } catch (e) {
      Logger.log('Failed to parse response as JSON:');
      Logger.log(response.getContentText());
      return; // Exit the function or handle the error as needed
    }

    

    // Proceed with processing the result if it's successfully parsed
    // Logger.log(JSON.stringify(result, null, 2));

  } else {
    var authorizationUrl = service.getAuthorizationUrl();
    Logger.log('Open the following URL and re-run the script: %s',
        authorizationUrl);
  }
}

/**
 * Reset the authorization state, so that it can be re-tested.
 */
function reset() {
  getService_().reset();
}

/**
 * Configures the service.
 * @param {string} optAccountServer The account server to use when requesting
 *     tokens.
 */
function getService_(optAccountServer) {
  var service = OAuth2.createService('Zoho')
      // Set the authorization base URL.
      .setAuthorizationBaseUrl('https://accounts.zoho.eu/oauth/v2/auth')

      // Set the client ID and secret.
      .setClientId(CLIENT_ID)
      .setClientSecret(CLIENT_SECRET)

      // Set scopes. See
      // I leave the scopes in here for troubleshooting
      //.setScope('ZohoRecruit.modules.READ')
      //.setScope('ZohoRECRUIT.modules.all')
      //.setScope('ZohoRECRUIT.org.all')
      .setScope('ZohoRecruit.org.all')
      //.setScope('ZohoCRM.org.all')    

      // Set the name of the callback function that should be invoked to
      // complete the OAuth flow.
      .setCallbackFunction('authCallback')

      // Set the access type to "offline" to get a refresh token.
      .setParam('access_type', 'offline')
      // Set prompt to "consent" to ensure a refresh token is retrieved.
      .setParam('prompt', 'consent')

      // Set the property store where authorized tokens should be persisted.
      .setPropertyStore(PropertiesService.getUserProperties())
      .setCache(CacheService.getUserCache());

      var token = service.getToken();
      Logger.log(token); // This will show you the structure of the token object


  // Set the token URL using the account server passed in or previously stored.
  var accountServer = optAccountServer ||
      service.getStorage().getValue('account-server');
  if (accountServer) {
    service.setTokenUrl(accountServer + '/oauth/v2/token');
  }
  return service;
}

/**
 * Handles the OAuth callback.
 */
function authCallback(request) {
  var accountServer = request.parameter['accounts-server'];
  var service = getService_(accountServer);
  var authorized = service.handleCallback(request);
  if (authorized) {
    // Save the account server in the service's storage.
    service.getStorage().setValue('account-server', accountServer);
    return HtmlService.createHtmlOutput('Success!');
  } else {
    return HtmlService.createHtmlOutput('Denied.');
  }
}

/**
 * Logs the redict URI to register.
 */
function logRedirectUri() {
  Logger.log(OAuth2.getRedirectUri());
}

----

Error log from Google App Script log:


2:03:46 PM Notice Execution started
2:03:46 PM Info {expiresAt=1.708956218E9, expires_in=3600.0, scope=ZohoRecruit.org.all, access_token=1000.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx, api_domain=https://www.zohoapis.eu, token_type=Bearer, refresh_token=1000.xxxxxxxxxxxxxxxxxxxxxx}
2:03:47 PM Info 400.0
2:03:47 PM Info {X-Content-Type-Options=nosniff, Date=Mon, 26 Feb 2024 13:03:46 GMT, Vary=accept-encoding, Server=ZGS, Content-Language=en-US, Content-Type=text/html;charset=UTF-8, Referrer-Policy=strict-origin, Content-Encoding=gzip, Connection=keep-alive, Transfer-Encoding=chunked, X-XSS-Protection=1, Set-Cookie=JSESSIONID=9CA8ABA2234F11A3F94B5AA4D7AC8CC0; Path=/; Secure; HttpOnly, Content-Security-Policy-Report-Only=script-src  'self' 'unsafe-eval' 'unsafe-inline' blob: https://*.zoho.com https://*.zoho.in https://*.zoho.com.au https://*.zoho.com.cn https://*.zoho.eu https://*.zohocdn.com https://*.stratuscdn.com  https://*.zohocdn.com.cn  https://*.zappsusercontent.com https://*.zappsusercontent.sa https://*.zappsusercontent.ca https://*.zappsusercontent.jp https://*.zappsusercontent.eu https://*.zappsusercontent.in https://*.zappsusercontent.com.au https://*.zappsusercontent.com.cn https://*.localzappscontents.com https://*.zohostatic.eu https://*.zohostatic.jp  https://js.skydeskstatic.jp https://*.zoho.eu https://media.twiliocdn.com/sdk/js/client/releases/1.7.7/twilio.min.js https://media.twiliocdn.com/sdk/js/client/v1.7/twilio.min.js https://cdn.pagesense.io https://s.ytimg.com/yts/jsbin/ https://ssl.google-analytics.com/ga.js https://www.youtube.com/iframe_api https://dyjgaef5vuq51.cloudfront.net https://dtzpfzv31buvf.cloudfront.net https://d22czkv2r5ogmg.cloudfront.net https://d12h6dzwzn4m10.cloudfront.net https://d17nz991552y2g.cloudfront.net  chrome-extension://*  https://www.google.com/recaptcha/ https://www.gstatic.com/recaptcha/  https://cdn.pagesense.io https://zohotagmanager.cdn.pagesense.io https://www.zohowebstatic.com/ https://scripts.zohospotlight.com https://widgets.zohosalesiq.com https://js.stripe.com https://connect.facebook.net; report-uri https://logsapi.zoho.com/csplog?service=crm, X-Frame-Options=SAMEORIGIN}
2:03:47 PM Info Logging output too large. Truncating output. <html><head><title>Zoho CRM - Error</title><link rel="SHORTCUT ICON" href="https&#x3a;&#x2f;&#x2f;static.zohocdn.com&#x2f;crm&#x2f;images&#x2f;favicon_cbfca4856ba4bfb37be615b152f95251_.ico" /><link href="https://static.zohocdn.com/crm/CRMClient/css/default_theme_b61f5f53b945c996ec11acc6fc077962_.css" rel="stylesheet" type="text/css"/><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta http-equiv="Pragma" content="no-cache"><style>
/******new error page style******/

I always get a generic Zoho error landing page which does not explain the error.

    • Topic Participants

    • Jens

    • Recent Topics

    • Zoho Developer Hangout (ZDH) – Episode 17 | Optimizing Organizational Processes through Automation

      Hey developers! Running a business can get quite overwhelming especially when juggling multiple tools like those in the Zoho ecosystem. Although integrating most of them is a piece of cake, manual intervention is needed at times. Being able to automate
    • Zoho One not working

      I'm having several issues accessing Zoho One. Some pages don't load (for example, Zoho Directory) and the labels are all messed-up (oz.account.directory.display.shorname, oz.settings...., etc.)
    • Apple Messages for Business in Omnichannel communications?

      Hello, Apple launched "Apple Messages for Business" but Zoho CRM or Zoho Desk don't appear in the list of possible integrators. Zoho already promotes https://www.zoho.com/crm/omnichannel.html Omni Channel integration, but Apple Messages does not yet appear.
    • Kaizen #140 - Integrating Blog feed scraping service into Zoho CRM Dashboard

      Howdy Tech Wizards! Welcome to a fresh week of kaizen. This week, we will look at how to create a dashboard widget that displays the most recent blog post of your preferred products/services, updated daily at a specific time. We will leverage the potential
    • Schedule meeting monthly on a particular day

      Suppose I wanted to schedule HR meeting every month on the first Tuesday with each employee separately for 20 minutes each. How could I automate these type of meetings? And if Sunday occurs on the first Tuesday I would like to shift that meeting on next
    • In ZohoCRM Dashboards - Editing Shown Columns on Drilldown of Components

      Hello! I'm working with some Dashboards inside of ZohoCRM. When creating a component (In this case, specifically a KPI Ranking Component), I'd like to customize which fields show when trying to drilldown. For example, when I click on one of the sales
    • Added Domain but SSL is not being set properly

      We added a Domain for our landing page and it pushed an SSL cert to it. The Cert is generated by LetsEncrypt, but it doesn't match our subdomain (i.e., it's just pointing to zohosites.com). How do we get the cert properly setup there?
    • Zoho CRM Widget not displaying 2 related lists (JS)

      Okay so I basically have 2 relatedLists that I want to get and render: ZOHO.CRM.API.getRelatedRecords({ Entity: data.Entity, RecordID: data.EntityId, RelatedList: "Notes", page: 1, per_page: 200, }) ZOHO.CRM.API.getRelatedRecords({ Entity: data.Entity,
    • KPI widget with percentage

      I'm trying to create a KPM widget that displays current performance as a percentage - something like the picture below. I've tried following the instructions at https://www.zoho.com/analytics/help/dashboard/kpi-widgets.html#chart but nothing ends up being
    • Canvas List View Not Saving

      Hi, I am trying to edit a list view to look different depending on the tags. Everything worked well and saved well with multiple views, but when I have gone back in to make some small changes like moving one of the icons it comes up with the error message
    • QR code image is not exported in PDFs

      The new QR code field works fine when I include it in a report template and I choose the print option: https://creatorapp.zoho.com/<username>/<app_link_name>/record-print/<report_link_name>/<record_ID>/ But when I try to save the document to a .pdf file
    • QR codes in templates

      I'm excited about the new QR code generator. I have included a QR code that contains the record ID setting "${ID}" as input data. In the report detail it works perfectly but when printing it in a template the code is not shown.
    • This mobile number has been marked spam. Please contact support.

      Hi Support, Can you tell me why number was marked as spam. I have having difficult to add my number as you keep requesting i must use it. My number is +63....163 Or is Zoho company excluding Philippines from their services?
    • Zoho CRM search not working

      The search bar is not showing any results in our CRM installation. We have a lot of items and can not search them by using the navigation each time. Can someone please check this asap.
    • Reload page with widget

      Hi all, I hope I can find some help here. I developed a small widget for Creator that is integrated into a page as a component. The page contains other content as well. When the widget is sent, the entire page should be reloaded to apply the changes to
    • Tip of the week #37 - Manage all your Telegram business conversations directly from your shared inboxes.

      Tired of switching between multiple apps to manage your business conversations? With Zoho TeamInbox's multichannel inboxes, connect your Telegram channel to a shared inbox. This way, your teams can easily handle c View, reply, and collaborate on them
    • Tags on notes aren't syncing correctly on Android

      I've created notes on the desktop version that have several tags assigned, but on both my Android devices those notes only have ONE of those tags instead of all of them, despite the actual content of the note being correctly synced, and I'm also starting
    • Reports - custom layout - duplicate report

      Do you also have this problem and what is the possible solution? I duplicate a report that has a "custom layout". Unfortunately the custom layout is not duplicated. To be improved for a future release by Zoho. I export the custom layout and import it...
    • How to map a global picklist from one module to another

      Hi there, i currently have a new field that is called sales office which we use for permission settings between our different offices located in different countries. It is a global set picklist with three different options: MY, SG and VN. I want to be
    • Pageless mode needed to modernise Writer

      When we switched from GSuite to Zoho, one of the easiest apps I found to give up, was Docs. In many ways, Writer has always been more powerful than Docs, especially in terms of workflows/fillable forms/etc. However, I went back into Docs because I notice
    • Changing the Logo Size on Zoho Sites

      My company logo incorporates both an image and text, and I would like it to be much more prominent on the page than is currently allowed by the small logo box in the template.  Is there any way to hide the page name and then make the logo box much bigger since my company name and logo are connected / are all in one file?  Thank you. 
    • Is it possible to Select Item Serial Numbers from a Sales Order?

      Our accepted estimates are converted to Sales orders for our warehouse staff to pick.  How can my warehouse staff select the serial numbers for an item when editing a Sales Order?  Logically when staff pull an item and have the serial in front of them they update the Sales Order and select the serial. I understand a serial can be added when creating an invoice but how can accounts team know the serial if the warehouse staff can't select it! A basic flaw!
    • MORE BUGS: Client Script, Deluge and Widget JS SDK don't work as expected when trying to retrieve a record that has been "rejected" as part of an approval process.

      Client Script $Page.record is null when accessing a record that has been "rejected" as part of an approval process. Deluge zoho.crm.getRecordById(moduleName, recordId) returns {"status":"failure"} when recordId is a valid, but rejected record. OK... I
    • Zoho CRM Widget not displaying 2 related lists (JS)

      Okay so I basically have 2 relatedLists that I want to get and render: ZOHO.CRM.API.getRelatedRecords({ Entity: data.Entity, RecordID: data.EntityId, RelatedList: "Notes", page: 1, per_page: 200, }) ZOHO.CRM.API.getRelatedRecords({ Entity: data.Entity,
    • Zoho Books and Zoho Projects Task Status Update

      How can we create an automation using custom functions for the following scenario. When our zoho books invoice status changes to paid. I want a task in Zoho projects to change to completed.
    • Assigning Tasks and Requests to Groups... how do I?

      Guys, I've spent many hours exploring Zoho Support and we are generally satisfied with the system.  I'm trying to understand how a system that has so much to offer can be missing GROUP assignment and queue functionality.  I am hoping that there is a way
    • Parsing of SQL query failed. Please check the SQL syntax.

      I am trying to have Zoho Analytics recognize that if the a Deal is in Stage "Need Docs" it should also be counted as a Deal in the Stage "New Lead" /*New Lead*/ SELECT "ID" 'New Lead' AS "Stage" From "Deals" Where "Stage" = 'Need Docs' Union All Error
    • Where is the setting to enable/disable 2FA?

      The following links show where enable/disable 2FA is supposed to appear, but neither appear for me: https://help.zoho.com/portal/en/kb/zohosites/faq/account/articles/how-do-i-enable-or-disable-two-factor-authentication-for-my-account shows Security >
    • How to Assign Record Ownership in a Custom Form via API?

      Hello everyone, I’ve created a custom form in Zoho People and I’m using the API to manage its records. I would like to know how I can assign ownership of these records to specific users via the API. Is there a specific parameter or field in the API request
    • Customer Statement Template not matching when sending

      Hi everyone! So when I send statements to our customers via Zoho Books, the message that appears by default does not match what I have written on the template Under settings -> email notifications -> sales -> customer statement We have a single default
    • Peppol Malaysia API

      Hi Zoho Books, my country Malaysia will going to implement "Peppol" (E-Invoicing), starting 1 Jul 2025 for all businesses. The government intends to provide API for accounting app. The workflow involves creating an invoice from accounting app, triggers
    • Re-emitir facturas con nueva dirección de facturación

      Hola, necesito saber si es posible que las facturas ya emitidas, pueden ser re-emitidas con el cambio de dirección de facturación, realizado el día de hoy 02-01-2025, para efectos contables. Espero su ayuda, Gracias
    • Zoho Learn vs. Trainer Central

      Hi, I'm currently using Zoho One with a WordPress-based website and WooCommerce to manage my online courses. I would like to know what is the difference between Zoho Learn and Trainer Central and if it's possible for these two platforms to replace WP
    • Map Plan to Different Income Account for Some Subscriptions via API

      We have a plan that has a default Plan Account of "Sales". Can we override the account for a specific subscription via API? In some instances the same exact plan should map to a different income account. When we create stand-alone invoices in Zoho Books,
    • Flow with CRM

      Hello, I have a simple flow that uses a web hook to enter data into a Sales Order. I have the web hook sending Flow data which has a PO field. If the PO has a special character like - or / or \ the task fails. How can I get the flow to be okay with the
    • Chrome browser issues. Anyone else?

      I am suddenly having multiple issues with Chrome browser interpreting the Zoho Mail interface.  Anyone else?  Any known problems? Thanks, Todd
    • Zoho Payroll US?

      Good morning, just reaching out today to see if there's any timeline, or if there's progress being made to bring Zoho Payroll out to be available to all states within the USA. Currently we're going through testing with zoho, and are having issues when
    • Set up multiple IMAP email addresses

      Hi, I just started using CRM and its great, but I just found out I can only add one imap email address for incoming mail in the included salesinbox ...this is ridiculous. All companies have different email such as sales@domain, info@domain , personal@domain
    • Function 58: Custom calculation in item table of invoices (2 fields)

      Hello everyone, and welcome back to our series! In Zoho Books, the Item Amount in invoices is calculated by multiplying the Quantity and Rate fields. Previously, we shared a function to include a custom field in this calculation. Today, we are taking
    • Tracking new lead response time

      Hi, I have a team of Sales Development Reps, who have a KPI of responding to a lead within 20 mins or less once it hits the system.  I seem to recall that Zoho CRM had the capability to track this in a previous version, but don't see it anywhere.   It's
    • Next Page