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.


      Zoho Campaigns Resources


        • Desk Community Learning Series


        • Digest


        • Functions


        • Meetups


        • Kbase


        • Resources


        • Glossary


        • Desk Marketplace


        • MVP Corner


        • Word of the Day


        • Ask the Experts


          • Topic Participants

          • Jens

          Zoho CRM Plus Resources

            Zoho Books Resources


              Zoho Subscriptions Resources

                Zoho Projects Resources


                  Zoho Sprints Resources


                    Zoho Orchestly Resources


                      Zoho Creator Resources


                        Zoho WorkDrive Resources



                          Zoho CRM Resources

                          • CRM Community Learning Series

                            CRM Community Learning Series


                          • Tips

                            Tips

                          • Functions

                            Functions

                          • Meetups

                            Meetups

                          • Kbase

                            Kbase

                          • Resources

                            Resources

                          • Digest

                            Digest

                          • CRM Marketplace

                            CRM Marketplace

                          • MVP Corner

                            MVP Corner




                            Zoho Writer Writer

                            Get Started. Write Away!

                            Writer is a powerful online word processor, designed for collaborative work.

                              Zoho CRM コンテンツ








                                ご検討中の方

                                  • Recent Topics

                                  • In the Zoho CRM Module I have TRN Field I should contain 15 digit Number , If it Contain less than 15 digit Then show Alert message on save of the button , If it not contain any number not want to sh

                                    Hi In the Zoho CRM Module I have TRN Field I should contain 15 digit Number , If it Contain less than 15 digit Then show Alert message on save of the button , If it not contain any number not want to show alert. How We can achive in Zoho CRm Using custom
                                  • Power of Automation::Streamline log hours to work hours upon task completion.

                                    Hello Everyone, A Custom Function is a user-written set of code to achieve a specific requirement. Set the required conditions needed as to when to trigger using the Workflow rules (be it Tasks / Project) and associate the custom function to it. Requirement:-
                                  • Zoho Bookings know-how: A hands-on workshop series

                                    Hello! We’re conducting a hands-on workshop series to help simplify appointment scheduling for your business with Zoho Bookings. We’ll be covering various functionalities and showing how you can leverage them for your business across five different sessions.
                                  • Custom report

                                    Hello Everyone I hope everything is fine. I've tried to To change the layout of the reports, especially the summary page report, and I want to divide summary of each section in the survey but I can't For example: I have a survey containing five different
                                  • Zoho Journey - ZOHO MARKETING AUTOMATION

                                    I’ve encountered an issue while working with a journey in Zoho Marketing Automation. After creating the journey, I wanted to edit the "Match Criteria" settings. Unfortunately: The criteria section appears to be locked and not editable. I’m also unable
                                  • Custom Fields in PDF outputs

                                    I created a couple of custom fields. e.g Country of Origin and HS Tariff Code. I need these to appear on a clone of a sales order PDF template but on on the standard PDF template. When I select "appear on PDFs' it appears on both but when I don't select
                                  • How to create a Service Agreement with Quarterly Estimate

                                    Hello, I'm not sure if this has been asked before so please don't get mad at me for asking. We're an NDIS provider in Australia so we need to draft a Service Agreement for our client. With the recent changes in the NDIS we're now required to also include
                                  • Change Currency symbol

                                    I would like to change the way our currency displays when printed on quotes, invoices and purchase orders. Currently, we have Australian Dollars AUD as our Home Currency. The only two symbol choices available for this currency are "AU $" or "AUD". I would
                                  • Python - code studio

                                    Hi, I see the code studio is "coming soon". We have some files that will require some more complex transformation, is this feature far off? It appears to have been released in Zoho Analytics already
                                  • Zoho Social - Post Footer Templates

                                    As a content creator I often want to include some information at the end of most posts. It would be great if there was an option to add pre-written footers, similar to the Hashtag Groups at the end of posts. For example, if there is an offer I'm running
                                  • Allow to pick color for project groups in Zoho Projects

                                    Hi Zoho Team, It would be really helpful if users could assign colors to project groups. This would make it easier to visually distinguish groups, improve navigation, and give a clearer overview when managing multiple projects. Thanks for considering
                                  • Zoho Books - Quotes to Sales Order Automation

                                    Hi Books team, In the Quote settings there is an option to convert a Quote to an Invoice upon acceptance, but there is not feature to convert a Quote to a Sales Order (see screenshot below) For users selling products through Zoho Inventory, the workflow
                                  • Can't find imported leads

                                    Hi There I have imported leads into the CRM via a .xls document, and the import is showing up as having been successful, however - when I try and locate the leads in the CRM system, I cannot find them.  1. There are no filters applied  2. They are not
                                  • Custom Button Disappearing in mobile view | Zoho CRM Canvas

                                    I'm working in Zoho CRM Canvas to create a custom view for our sales team. One of the features I'm adding is a custom button that opens the leads address in another tab. I've had no issue with this in the desktop view, but in the mobile view the button
                                  • The connected workflow is a great idea just needs Projects Integrations

                                    I just discovered the connected workflows in CRM and its a Great Idea i wish it was integrated with Zoho Projects I will explain our use case I am already trying to do something like connected workflow with zoho flow Our requirement was to Create a Task
                                  • Zoho Projects MCP Feedback

                                    I've started using the MCP connector with Zoho Projects, and the features that exist really do work quite well - I feel this is going to be a major update to the Zoho Ecosystem. In projects a major missing feature is the ability to manage, (especially
                                  • Function #10: Update item prices automatically based on the last transaction created

                                    In businesses, item prices are not always fixed and can fluctuate due to various factors. If you find yourself manually adjusting the item rates every time they change, we have the ideal time-saving solution for you. In today's post, we bring you custom
                                  • email template

                                    How do I create and save an email template
                                  • Enhancements in Portal User Group creation flow

                                    Hello everyone, Before introducing new Portal features, here are some changes to the UI of Portals page to improve the user experience. Some tabs and options have been repositioned so that users can better access the functionalities of the feature. From
                                  • Archiving Contacts

                                    How do I archive a list of contacts, or individual contacts?
                                  • How do I filter contacts by account parameters?

                                    Need to filter a contact view according to account parameter, eg account type. Without this filter users are overwhelmed with irrelevant contacts. Workaround is to create a custom 'Contact Type' field but this unbearable duplicity as the information already
                                  • Can I add Conditional merge tags on my Templates?

                                    Hi I was wondering if I can use Conditional Mail Merge tags inside my Email templates/Quotes etc within the CRM? In spanish and in our business we use gender and academic degree salutations , ie: Dr., Dra., Sr., Srta., so the beginning of an email / letter
                                  • Zoho CRM button to download images from image upload field

                                    Hello, I am trying to create a button in Zoho CRM that I can place in my record details view for each record and use it to download all images in the image upload fields. I tried deluge, client scripts and even with a widget, but feel lost, could not
                                  • email moderation issue when email is sent in the name of a mail group

                                    Symptom: an email that is sent by a mail group moderator in the name of a moderated mail group is held back for approval. Reproduction: Create a moderated mail group with members and moderators. Allow that mails can be sent in the name of the group (extended settings). Send an email to the group as a group moderator, but in the name of the group. This mail is held back for moderation which is unexpected. Expected: A mail sent by group moderator to a moderated group are not held back for moderation
                                  • blank page after login

                                    blank page after logging into my email account Thanks you
                                  • Introducing the revamped What's New page

                                    Hello everyone! We're happy to announce that Zoho Campaigns' What's New page has undergone a complete revamp. We've bid the old page adieu after a long time and have introduced a new, sleeker-looking page. Without further ado, let's dive into the main
                                  • Always display images from this sender – Is this feature available?

                                    In Zoho mail, I had my "Load external images" setting set to "Ask me", and that's fine. That's the setting I prefer. What's not fine though is I always need to tick "Display now" for each email I get, regardless if I've done that multiple times from several
                                  • Function #9: Copy attachments of Sales Order to Purchase Order on conversion

                                    This week, we have written a custom function that automatically copies the attachments uploaded for a sales order to the corresponding purchase order after you convert it. Here's how to configure it in your Zoho Books organization. Custom Function: Hit
                                  • Free webinar: Security that works: Building resilience for the AI-powered workforce

                                    Hello there, Did you know that more than 51% of organizations worldwide have experienced one or more security breaches, each costing over $1 million in losses or incident response? In today’s threat landscape, simply playing defense is no longer enough.
                                  • "Subject" or "Narration"in Customer Statement

                                    Dear Sir, While creating invoice, we are giving in "Subject" the purpose of invoice. For Example - "GST for the month of Aug 23", IT return FY 22-23", "Consultancy", Internal Audit for May 23". But this subject is not coming in Customer Statement. Only
                                  • Apply Vendor Credit Automatically

                                    Hello!!! Is there a way where in we can apply vendor credits automatically on the FIRST OUTSTANDING BILL of the vendor?? We have lots of VENDOR CREDITS ISSUES mostly!!! Applying it manually is a pain for us. Would be great if we have a way to apply the
                                  • Zoho Notebook Sync problem

                                    I'm facing a problem with syncing of notebook on android app. It's not syncing. Sometimes it syncs after a day or two.  I created some notes on web notebook but it's not syncing on mobile app. Please help!!!!
                                  • Cliq iOS can't see shared screen

                                    Hello, I had this morning a video call with a colleague. She is using Cliq Desktop MacOS and wanted to share her screen with me. I'm on iPad. I noticed, while she shared her screen, I could only see her video, but not the shared screen... Does Cliq iOS is able to display shared screen, or is it somewhere else to be found ? Regards
                                  • Retainer Invoice.

                                    Why ZOHO not have facilities to deduct partially advance payment from an invoice.
                                  • Apply Vendor Credits Automatically

                                    We are bulk importing Vendor credits in Zoho Books!!! Is there a way to apply vendor credits automatically to the first UNPAID bill of the Vendor?
                                  • Cant Save Gauge on Creator Page

                                    How to Save Gauge on Creator Page see movie https://vimeo.com/1116410860?share=copy#t=0
                                  • Apply Advance option not shown in report

                                    We are facing an issue in Zoho Expenses. While approving an Expense Report, the "Apply Advance" option is not appearing under the three dots (More Options). Details: Module: Expense Reports Issue: "Apply Advance" option not visible Status of Report: Awaiting
                                  • Introducing Assemblies and Kits in Zoho Inventory

                                    Hello customers, We’re excited to share a major revamp to Zoho Inventory that brings both clarity and flexibility to your inventory management experience! Presenting Assemblies and Kits We’re thrilled to introduce Assemblies and Kits, which replaces the
                                  • Auto Capitalize First Letter of Words

                                    Hi I am completely new to ZOHO and am trying to build a database. How can i make it when a address is entered into a form field like this: main st it automatically changes is to show: Main St Thank You
                                  • Follow-up emails via Workflow Automation not staying in the same thread

                                    Dear Zoho Support Team, I am currently using Workflow Automation in Zoho Campaigns to send follow-up emails. In my test case, I noticed the following behavior: All emails in the automation have the same subject line. If the follow-up email is sent within
                                  • Next Page