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.


    Zoho Desk Resources

    • Desk Community Learning Series


    • Digest


    • Functions


    • Meetups


    • Kbase


    • Resources


    • Glossary


    • Desk Marketplace


    • MVP Corner


    • Word of the Day


      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 Campaigns 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 コンテンツ




                              ご検討中の方