Step 1. Host the API and change the web config file. ----------------------------------------------------------------------------------------------------------------------------------- Step 2. Run the below Stored Procedure. CREATE PROCEDURE [dbo].[udsp_sp_AmsComtel_insertlead_data] ( @nServiceId varchar(100), @szLeadDate varchar(100), @szCustomerName varchar(100), @szContactNumber varchar(100), @szPolicyNumber varchar(100), @szPlanName varchar(100), @szAnnualPremium varchar(100), @szFundSurrenderValue varchar(100), @szCustomerToPay varchar(100), @szIssueDate varchar(100), @szDueDate varchar(100), @szBusinessPartner varchar(100), @szAgentName varchar(100), @szAgentCode varchar(100) ) AS BEGIN DECLARE @strTemp AS varchar(max) DECLARE @nSourceCount as Int DECLARE @strTableDbName AS varchar(999) DECLARE @leadmaster_table AS varchar(999) DECLARE @ServiceName AS varchar(100) DECLARE @Batch AS varchar(15) DECLARE @LeadStatus AS varchar(50) SET @LeadStatus = 'Inserted' SELECT @strTableDbName = service_outbound_lead_db_name, @leadmaster_table = service_leadstructure_master_tablename, @ServiceName = service_name FROM cti_services WHERE service_id = @nServiceId Set @Batch = 'Batch_'+Replace(convert(varchar(10),getdate(),23),'-','') SET @strTemp = 'INSERT INTO '+@strTableDbName+'..'+ @leadmaster_table +' ( lead_service_id, lead_import_batch_id, lead_import_batch_no, lead_zone, lead_phone1, lead_fname, lead_lname, udf_lead_date, udf_policy_number, udf_plan_name, udf_annual_premium, udf_fund_surrender_value, udf_customer_to_pay, udf_issue_date, udf_due_date, udf_business_partner, udf_agent_code, lead_import_batch_start_date, lead_import_batch_end_date, lead_call_type, lead_status, lead_next_dial_time, lead_attempts, lead_used,lead_fix_agent,lead_dialable ) VALUES ( '''+@nServiceId+''', 0, ''' + @Batch+''', ''AAA'', '''+ @szContactNumber+''', '''+ @szCustomerName+''', '''+ @szAgentName+''', '''+ @szLeadDate+''', '''+ @szPolicyNumber +''', '''+ @szPlanName +''', '''+ @szAnnualPremium +''', '''+ @szFundSurrenderValue +''', '''+ @szCustomerToPay +''', '''+ @szIssueDate +''', '''+ @szDueDate +''', '''+ @szBusinessPartner +''', '''+ @szAgentCode +''', GETDATE(), DATEADD(YEAR, 10, GETDATE()), ''I'', ''P'', DATEADD(MI, 30, GETDATE()), 0, ''N'',0,''Y'')' EXEC(@strTemp) Select @@Identity As LeadId ,@LeadStatus AS LeadStatus set @nSourceCount=0 select @nSourceCount = count(*) from cti_lead_batch_master where Leadimport_Batch_name = @Batch and leadimport_service_id = @nServiceId group by Leadimport_Batch_name if @nSourceCount <= 0 BEGIN INSERT INTO [CTI_Lead_Batch_Master] ([leadimport_service_id] ,[leadimport_service_name] ,[leadimport_template_id] ,[leadimport_template_name] ,[leadimport_vendor_id] ,[leadimport_vendor_name] ,[leadimport_batch_name] ,[leadimport_country_code] ,[leadimport_source_type] ,[leadimport_source_name] ,[leadimport_source_count] ,[leadimport_import_count] ,[leadimport_rejected_count] ,[leadimport_rejected_dnc] ,[leadimport_rejected_invalid] ,[leadimport_rejected_fieldrules] ,[leadimport_rejected_zones] ,[leadimport_rejected_duplicate] ,[leadimport_rejected_error] ,[leadimport_imported_by_id] ,[leadimport_imported_by_name] ,[leadimport_imported_on_computer] ,[leadimport_imported_on_date] ,[leadimport_summary] ,[leadimport_batch_status] ,[leadimport_batch_refill_percentage] ,[leadimport_batch_usage_percentage] ,[Leadimport_zone] ,[Leadimport_batch_fix_agents] ,[leadimport_batch_start_date] ,[leadimport_batch_end_date]) VALUES (@nServiceId,'' + @ServiceName + '',-1,'',-1,'','' + @Batch + '','','E','SQLPROCEDURE', 1,1,0,0,0,0,0,0,0,0,'TSPL','TSPL',getdate(),'','A','',0,'AAA','N',GETDATE(),DATEADD(YEAR,10,GETDATE())) END ELSE BEGIN UPDATE CTI_Lead_Batch_Master Set leadimport_source_count = leadimport_source_count + 1 , leadimport_import_count = leadimport_import_count + 1 WHERE Leadimport_Batch_name =@Batch AND leadimport_service_id = @nServiceId AND leadimport_zone = 'AAA' END END ----------------------------------------------------------------------------------------------------------------------------------- Step 3. use below queuries for testing. Method - POST URL - http://:/api/Leadpush/PushLead Body -> row -> Json { "ServiceId":"57", "LeadDate":"2023-06-21 00:00:00", "CustomerName":"XYZ", "ContactNumber":"1234567890", "PolicyNumber":"12345", "PlanName":"ABC", "AnnualPremium":"2000", "FundSurrenderValue":"0", "CustomerToPay" :"15000", "IssueDate":"2023-06-10 00:00:00", "DueDate":"2023-06-22 00:00:00", "BusinessPartner":"abcd", "AgentName":"Mr.Nobody", "AgentCode":"007" }