Esempio n. 1
0
        /// <summary>
        /// Sample code for finding a single resource - requires the query field to be a unique value. In this sample ExternalContactId.
        /// </summary>
        static void FindSingleResource()
        {
            string userName          = ConfigurationManager.AppSettings["UserName"];
            string password          = ConfigurationManager.AppSettings["Password"];
            string bulkURL           = ConfigurationManager.AppSettings["BulkURL"];
            string externalContactId = "IDX99";

            BulkSamples bulkSamples = new BulkSamples();
            string      query       = "/api/bulk/2.0/find/Contact?fields=Id, ExternalContactId,FirstName,LastName,Email,Phone&query=ExternalContactId='" + externalContactId + "'";

            List <Resource> resources = bulkSamples.FindResources(bulkURL + query, userName, password);

            if (resources.Count > 0)
            {
                Resource resource = resources[0];  // ExternalContactId is unique, there will be one or zero resources returned.
                foreach (var field in resource.Field)
                {
                    Console.WriteLine("Field: " + field.Id + " Value: " + field.Value);
                }
            }
            else
            {
                Console.WriteLine("Contact with ExternalContactId {0} could not be retrieved or does not exist.", externalContactId);
            }

            Console.WriteLine("Done");
            Console.ReadKey();
        }
Esempio n. 2
0
        /// <summary>
        /// Sample code for creating Contact resources with the resource descriptions provided in a file.
        /// </summary>
        static void BulkCallBulkCreateWithInputFile()
        {
            string      userName    = ConfigurationManager.AppSettings["UserName"];
            string      password    = ConfigurationManager.AppSettings["Password"];
            string      bulkURL     = ConfigurationManager.AppSettings["BulkURL"];
            BulkSamples bulkSamples = new BulkSamples();
            string      create      = "/api/bulk/2.0/Create/Contact";

            bulkSamples.WebClientBulkCreateUsingFile(bulkURL + create, "upload.psv", userName, password);
        }
Esempio n. 3
0
        /// <summary>
        /// Sample code for querying multiple resources and storing the results in a file.
        /// </summary>
        static void BulkFindMultipleResources()
        {
            //  Find Single Resource
            string      userName    = ConfigurationManager.AppSettings["UserName"];
            string      password    = ConfigurationManager.AppSettings["Password"];
            string      bulkURL     = ConfigurationManager.AppSettings["BulkURL"];
            BulkSamples bulkSamples = new BulkSamples();

            string query = "/api/bulk/2.0/find/Contact?fields=Id,FirstName,LastName,Email,Phone&query=LastName+IS+NOT+NULL&limit=10";

            bulkSamples.WebClientFindToFile(bulkURL + query, userName, password);
        }