Zoho CRM API: Python request-based POST or GET authentication + insertion of contacts

Zoho CRM API: Python request-based POST or GET authentication + insertion of contacts

The Task##

A django application that allows users to sign up and once the user clicks on the account activation link, Zoho CRM is receiving the data and a contact is created in the CRM section. Olansi Air Purifier

The Problem

I am currently working on an absolute masterpiece - the ZOHO API. I am struggling to set up the native Python code that uses POST/GET requests. Regarding the zcrmsdk 3.0.0, I have completely given up on this solution unless somebody can provide a fully functional example. The support simply blames my code.

The documentation I consulted: 

Generate Access Token and Refresh Token
Insert Records API

Since the post request in postman API works fine I do not understand why it does not work in python code

My approach

  1. Generate an self-client API code on: api-console
  2. Insert that code on Postman and retrieve the access or refresh token
  3. Use this access token in an add_user_contact function that is defined in the documentation It works! Response is success and it is in Zoho CRM

The permsissions scope I am using is: ZohoCRM.modules.contacts.ALL, ZohoCRM.users.ALL, ZohoCRM.modules.deals.ALL, ZohoCRM.modules.attachments.ALL, ZohoCRM.settings.ALL, AAAserver.profile.ALL



My own Code

  1. def authenticate_crm():
    
    """
    access to response object id:
    response_object.get('data')[0].get('details').get('id')
    """
    
    url = 'https://accounts.zoho.com/oauth/v2/token'
    
    headers = {
        'Content-Type': 'application/x-www-form-urlencoded'
    }
    
    # one time self-client token here -
    request_body = {
        "code": "1000.aa8abec144835ab79b8f9141fa1fb170.8ab194e4e668b8452847c7080c2dd479",
        "redirect_uri": "http://example.com/yourcallback",
        "client_id": "1000.H95VDM1H9KCXIADGF05E0E1XSVZKFQ",
        "client_secret": "290e505ec52685fa62a640d874e6560f2fc8632e97",
       " grant_type": "authorization_code"
    }
    
    response = requests.post(url=url, headers=headers, data=json.dumps(request_body).encode('utf-8'))
    if response is not None:
        print("HTTP Status Code : " + str(response.status_code))
        print(response.json())

I am essentially struggling to convert the Postman API request to a Python request to get the token as part of the workflow. What am I doing wrong here?

The documentation states: Note: For security reasons, pass the below parameters in the body of your request as form-data. (access-refresh link) but passing it in postman as form-data breaks the call completely.

According to their own documentation (which is convoluted, contradictory and full of outdated screenshots) the authentication key is needed only once. Once the request from above runs, I would take the response in the third image and use the refresh key to add the contact. I am also open to a solution with the SDK 3.0.0, if anybody can help.


    • Sticky Posts

    • Kaizen #226: Using ZRC in Client Script

      Hello everyone! Welcome to another week of Kaizen. In today's post, lets see what is ZRC (Zoho Request Client) and how we can use ZRC methods in Client Script to get inputs from a Salesperson and update the Lead status with a single button click. In this
    • Kaizen #222 - Client Script Support for Notes Related List

      Hello everyone! Welcome to another week of Kaizen. The final Kaizen post of the year 2025 is here! With the new Client Script support for the Notes Related List, you can validate, enrich, and manage notes across modules. In this post, we’ll explore how
    • Kaizen #217 - Actions APIs : Tasks

      Welcome to another week of Kaizen! In last week's post we discussed Email Notifications APIs which act as the link between your Workflow automations and you. We have discussed how Zylker Cloud Services uses Email Notifications API in their custom dashboard.
    • Kaizen #216 - Actions APIs : Email Notifications

      Welcome to another week of Kaizen! For the last three weeks, we have been discussing Zylker's workflows. We successfully updated a dormant workflow, built a new one from the ground up and more. But our work is not finished—these automated processes are
    • Kaizen #152 - Client Script Support for the new Canvas Record Forms

      Hello everyone! Have you ever wanted to trigger actions on click of a canvas button, icon, or text mandatory forms in Create/Edit and Clone Pages? Have you ever wanted to control how elements behave on the new Canvas Record Forms? This can be achieved