Salesforce API create Contact using Java

package com.thysmichels;

import com.sforce.soap.partner.*;
import com.sforce.soap.partner.sobject.*;

public class ForcedotcomAWS {

	 * @param args
	public static void main(String[] args) {
		// TODO Auto-generated method stub
	    //Create a new connectionconfig to your Salesforce Org
	    ConnectorConfig sfconfig = new ConnectorConfig();
		//Use your salesforce username = email
	    //Use your saleforce password with your security token look like: passwordjeIzBAQKkR6FBW8bw5HbVkkkk
	    PartnerConnection partnercon = null;
	    try {
	        // create a salesforce connection object with the credentials supplied in your connectionconfig
	        partnercon = Connector.newConnection(sfconfig);
                SObject contact = new SObject();
	        contact.setField("Salutation", "Mr.");
	        contact.setField("FirstName", "Thys");
	        contact.setField("LastName", "Michels");
	        contact.setField("Title", "Software Engineer");
	        contact.setField("Department", "IT");
	        contact.setField("Phone", "4084213377");
	        contact.setField("Email", "");
	        contact.setField("LeadSource", "Web");
// safe contact object
	        SaveResult[] sfcontactresults = partnercon.create(new SObject[] { contact });
	        System.out.println("Created Contact: " + sfcontactresults[0].getId());
	    } catch (ConnectionException e) {
	        // TODO Auto-generated catch block

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

Join 290 other followers

%d bloggers like this: