How To Create Contacts Using Zoho CRM In ASP.NET MVC

Introduction

In this article, we will learn how to create a Contact using Zoho CRM in ASP.NET MVC Web application.

Let’s begin

Please read this article first of all here.

C# Code Example

Open the HomeController.cs file and add the below code in it.

public void CreateContacts()
 {
     ZCRMModule moduleIns1 = ZCRMModule.GetInstance("accounts"); //module api name
     BulkAPIResponse<ZCRMRecord> response1 = moduleIns1.GetRecords();
     List<ZCRMRecord> relatedLists = response1.BulkData;
     List<ZCRMRecord> listRecord = new List<ZCRMRecord>();
     ZCRMRecord record;

     record = ZCRMRecord.GetInstance("contacts", null); //To get ZCRMRecord instance
     
     record.SetFieldValue(relatedLists[0].CreatedBy.FullName, relatedLists[0].CreatedBy.Id);
     record.SetFieldValue("Company", "test");
     record.SetFieldValue("Last_Name", "test");
     record.SetFieldValue("Customfield", "CustomFieldValue");
     
     listRecord.Add(record);

     ZCRMModule moduleIns = ZCRMModule.GetInstance("contacts");
    
     BulkAPIResponse<ZCRMRecord> responseIns = moduleIns.CreateRecords(listRecord); //To call the create record method

     Console.WriteLine("HTTP Status Code:" + responseIns.HttpStatusCode); //To get create record http response code
    
 }

 

Get All Contacts Data

Open the HomeController.cs file and add the below code in it.

public void GetAllContactsData()
 {
     ZCRMModule moduleIns = ZCRMModule.GetInstance("contacts"); //module api name
     BulkAPIResponse<ZCRMRecord> response = moduleIns.GetRecords();
     List<ZCRMRecord> relatedLists = response.BulkData;
 }

 

if you have any questions or issues about this article, please let me know and more details here.

Submit a Comment

Your email address will not be published. Required fields are marked *

Subscribe

Select Categories