0

I am trying to create contact from my application of java in infusion soft, but failed to get response. sometime i got connection timeout error, sometime got error 596.

My example code is under fellow:

public static void addContact() {
try {
//Sets up the java client, including the api url
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
config.setEnabledForExtensions(true);
config.setConnectionTimeout(60 * 1000);
config.setReplyTimeout(60 * 1000);
config.setServerURL(new URL(\"https://api.infusionsoft.com/\"));
XmlRpcClient client = new XmlRpcClient();
client.setConfig(config);

//The secure encryption key
String key = \"sdfsdfsdfsdfs34534534534534\";

/**
* ***********************************************
* *
* ADD CONTACT TO DATABASE *
* ***********************************************
*/
List parameters = new ArrayList();
Map contactData = new HashMap();
contactData.put(\"FirstName\", \"Java John\");
contactData.put(\"LastName\", \"Doe\");
contactData.put(\"Email\", \"john@doe.com\");

parameters.add(key); //The secure key
//parameters.add(\"Contact\"); //The table we will be adding to
parameters.add(contactData); //The data to be added

//Make the call
Integer contactId = (Integer) client.execute(\"ContactService.add\", parameters);
System.out.println(\"Contact added was \" + contactId);
} catch (MalformedURLException ex) {
System.out.println(ex);
} catch (XmlRpcException ex) {
System.out.println(ex);
}
}

how do i create a contact in infusion soft using XMLRPC service in java? can i have example code?

Irfan Nasim
  • 1,952
  • 2
  • 19
  • 29

1 Answers1

0

This is complete code to create a contact in infusion soft.

Key: The key parametter is the secret key provided by the infusion soft while creating account

URL: "https://myApp.infusionsoft.com:443/api/xmlrpc", need to write name of your app on the place of 'myApp'.

public static void addContact() {
        try {
            //Sets up the java client, including the api url
            XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
            config.setServerURL(new URL("https://myApp.infusionsoft.com:443/api/xmlrpc"));
            XmlRpcClient client = new XmlRpcClient();
            client.setConfig(config);

            //The secure encryption key
            String key = "34534k34h5k34hj34k5hhk";

            /**
             * ***********************************************
             *                                               *
             * ADD CONTACT TO DATABASE *
             * ***********************************************
             */
            List parameters = new ArrayList();
            Map contactData = new HashMap();
            contactData.put("FirstName", "Java John");
            contactData.put("LastName", "Doe");
            contactData.put("Email", "john@doe.com");

            parameters.add(key); //The secure key
            //parameters.add("Contact"); //The table we will be adding to
            parameters.add(contactData); //The data to be added

            //Make the call
            Integer contactId = (Integer) client.execute("ContactService.add", parameters);
            System.out.println("Contact added was " + contactId);
        } catch (MalformedURLException ex) {
            System.out.println(ex);
        } catch (XmlRpcException ex) {
            System.out.println(ex);
        }
    }

It is complete working code after spending 3 days i am able to get solution.

Irfan Nasim
  • 1,952
  • 2
  • 19
  • 29