1

I am new to salesforce and trying to integrate basic windows app with click to sales force lead. I some how done my research successfully connected to salesforce API my next step is to load data into salesforce lead .

        private SforceService binding;
        private LoginResult lr;



        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (login())
            {
                describeGlobal();
            }
        }

        private bool login()
        {
            try
            {
                binding = new SforceService();
                binding.Timeout = 6000;
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;

                lr = binding.login("username", "password" );
                return true;
            }
            catch (SoapException e)
            {
                MessageBox.Show(e.Message);
            }
            return false;
        }
        private void describeGlobal()
        {
            binding.Url = lr.serverUrl;
            #region[Consume Enterprise webservice]

            binding.SessionHeaderValue = new SFDC_Enterprise_WSDL.SessionHeader();
            binding.SessionHeaderValue.sessionId = lr.sessionId;
            #endregion

            //describeGlobal returns an array of object results that
            //includes the object names that are available to the logged-in user

            DescribeGlobalResult dgr = binding.describeGlobal();

            //Loop through the array echoing the object names to the console
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < dgr.sobjects.Length; i++)
            {
                sb.Append(dgr.sobjects[i].name + " , ");
            }
            MessageBox.Show(sb.ToString());
        }

    }
    }

this is my code which got connected to sales force API. But i cannot find any documents which can guide me to load data into sales force.

enter image description here

2

1 Answer 1

2

It looks like you are using the using the SOAP Partner API.

You basically carry on like you did with the describeGlobal call.

  1. Make sure the binding has the serverUrl and SessionHeaderValue set with the results from the login call.
  2. Create a collection of sObject records for the leads you want to insert/update. Populate the fields on these using XML elements in the Any property.
  3. Call the create/update/upsert methods with the collection of sObjects.
  4. Check the SaveResult records for any problems.

See also:

2
  • where can i find sessionHeadervalue set and server url is the one which we use for consuming API rite? Feb 2, 2017 at 1:10
  • @suriyadevp You do it already in the first few lines of your describeGlobal method. Feb 2, 2017 at 1:25

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .