/// <summary> /// Use Enterprise API to create new SFDC records /// </summary> /// <param name="sessionId"></param> /// <param name="serverUrl"></param> private static void CreateEnterpriseRecords() { Console.WriteLine("Creating an account record with the Enterprise API ..."); //set query endpoint to value returned by login request EndpointAddress apiAddr = new EndpointAddress(serverUrl); //instantiate session header object and set session id enterprise.SessionHeader header = new enterprise.SessionHeader(); header.sessionId = sessionId; //create service client to call API endpoint using (enterprise.SoapClient createClient = new enterprise.SoapClient("Soap", apiAddr)) { enterprise.Account newAcct = new enterprise.Account(); newAcct.Name = "DevForce02"; newAcct.AccountNumber = "10043332"; //all non-string fields must have their corresponding <name>Specified property set newAcct.AnnualRevenue = 4000000f; //newAcct.AnnualRevenueSpecified = true; enterprise.Opportunity o = new enterprise.Opportunity(); o.Name = "Opp2"; o.StageName = "Prospecting"; o.CloseDate = DateTime.Parse("2013-03-22"); o.CloseDateSpecified = true; enterprise.SaveResult[] results; createClient.create( header, //sessionheader null, //assignmentruleheader null, //mruheader null, //allowfieldtruncationheader null, //disablefeedtrackingheader null, //streamingenabledheader null, //allornoneheader null, //debuggingheader null, //packageversionheader null, //emailheader new enterprise.sObject[] { o }, //objects to add out results //results of the creation operation ); //only added one item, so looking at first index of results object if (results[0].success) { Console.WriteLine("Account successfully created."); } else { Console.WriteLine(results[0].errors[0].message); } Console.ReadLine(); } }