public void BulkExportLeads() { Console.WriteLine("============================Getting token=============================="); Console.WriteLine("============================Creating job=============================="); LeadsExportRequest leadsExportRequest = _requestFactorty.CreateGetLeadsExportRequest(_host, _token); string job = LeadsHttpProcessor.CreateJob(leadsExportRequest); Console.WriteLine("============================Getting exportedId=============================="); JObject jobObject = (JObject)JsonConvert.DeserializeObject(job); JToken result = jobObject["result"]; string exportedId = result[0]["exportId"].ToString(); leadsExportRequest.ExportId = exportedId; Console.WriteLine("============================Enqueuing job " + exportedId + "=============================="); LeadsHttpProcessor.EnqueueJob(leadsExportRequest); string status = LeadsHttpProcessor.GetJobStatus(leadsExportRequest); while (status != "Completed") { System.Threading.Thread.Sleep(1 * 60 * 1000); status = status = LeadsHttpProcessor.GetJobStatus(leadsExportRequest); //Console.WriteLine("==============================Waiting job to be completed====================================="); Console.WriteLine("==============================" + status + "====================================="); } if (LeadsHttpProcessor.GetJobStatus(leadsExportRequest) == "Completed") { Console.WriteLine("==========================Job Completed, Start to retrieving==============================="); string extractedData = LeadsHttpProcessor.RetrieveData(leadsExportRequest); System.IO.File.WriteAllText(@"D:\List_Import_Leads.csv", extractedData); Console.WriteLine("==========================Done!==============================="); Console.ReadKey(); } }