You are here: Customers and Contacts > createContact

Create Contact

Description

Create a contact with the given parameters.

Default Protocol Method Type URI
HTTPS POST createContact.xml

Post Parameters

Parameter Description Valid Values Optional
emailId Contact e-mail ID String No
contactName Contact name String Yes
contactNumber Contact number String Yes
contactPassword Login password String Yes
loginAllowed

Set to one of the following to specify if login is required for the contact:

  • True: Login is required.
  • False: Login is not required.

Default Value: True

Boolean Yes
customerId The unique record ID of the customer in EMS database. Integer Yes
shipAddr Shipping address String Yes
shipAddrCity Shipping address - city String Yes
shipAddrCountry Shipping address - country String Yes
shipAddrState Shipping address - state String Yes
shipAddrZip Shipping address - zip String Yes
billAddr Billing address - billing address String Yes
billAddrCity Billing address - city String Yes
billAddrCountry Billing address - country String Yes
billAddrState Billing address - state String Yes
billAddrZip Billing address - zip String Yes
refId1 Information that uniquely identifies the contact in a different ERP system. String Yes
refId2 A second unique reference ID, similar to Ref ID 1. String Yes

Sample Code

import java.io.IOException;
//..............................
//..............................
//..............................
import org.apache.http.params.HttpParams;
public class EMSSample {
        private static DefaultHttpClient httpclient = new DefaultHttpClient();
        private static Principal principal = null;
        //..............................
        //..............................
        //..............................
        public static String createContact.xml()throws Exception {
                if(!verifyLogin()){
                        return "login failed";
                }
                HttpContext context = new BasicHttpContext();
                context.setAttribute(ClientContext.USER_TOKEN, principal);
                HttpPost post = new HttpPost("https://localhost:8443/ems/3.6/createContact.xml");
                List<NameValuePair> nvps = new ArrayList<NameValuePair>();
                nvps.add(new BasicNameValuePair("billAddr", ""));
                nvps.add(new BasicNameValuePair("contactNumber", ""));
                nvps.add(new BasicNameValuePair("billAddrCity", ""));
                nvps.add(new BasicNameValuePair("shipAddrCountry", ""));
                nvps.add(new BasicNameValuePair("shipAddrCity", ""));
                nvps.add(new BasicNameValuePair("billAddrZip", ""));
                nvps.add(new BasicNameValuePair("shipAddr", ""));
                nvps.add(new BasicNameValuePair("billAddrState", ""));
                nvps.add(new BasicNameValuePair("loginAllowed", ""));
                nvps.add(new BasicNameValuePair("shipAddrState", ""));
                nvps.add(new BasicNameValuePair("contactPassword", ""));
                nvps.add(new BasicNameValuePair("refId2", ""));
                nvps.add(new BasicNameValuePair("emailId", ""));
                nvps.add(new BasicNameValuePair("billAddrCountry", ""));
                nvps.add(new BasicNameValuePair("customerId", ""));
                nvps.add(new BasicNameValuePair("refId1", ""));
                nvps.add(new BasicNameValuePair("contactName", ""));
                nvps.add(new BasicNameValuePair("shipAddrZip", ""));
                post.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
                HttpResponse response = httpclient.execute(post, context);
                HttpEntity entity = response.getEntity();
                byte[] b = null;
                if (entity != null) {
                        long l = entity.getContentLength();
                        b = new byte[(int) l];
                        entity.getContent().read(b);
                        entity.consumeContent();
                }
                return new String(b);
        }
}

Sample Response

<?xml version="1.0" encoding="UTF-8"?>
<emsResponse>
   <contactId>1</contactId>
   <stat>ok</stat>
</emsResponse>
 
See Also:

Output Format for Failure

Error Codes

Error Code Description
100 Invalid request parameter.
101 You are not authorized to use this service.
107 An internal error occurred! Please report the error to System administrator.
113 Specify a valid Boolean value for {field}. Valid values are true or false. [Note: This error code is applicable for the fields - fetchCompleteEID, loginAllowed, isEnabled, vmEnabled, clonePotection, and optional.].
115 Length of {field} is {actual value}. It cannot be more Than {max value}. [Note: This error code is applicable for the fields - billAddr, billAddrCity, billAddrCountry, billAddrState, billAddrZip, shipAddr, shipAddrCity, shipAddrCountry, shipAddrState, shipAddrZip, refId1, refId2, contactPassword, description, and default value.]
117 Regular Expression validation failed for contactEmailId
120 {field} value is less than the minimum permitted value {value}. [Note: This error code is applicable for the fields - productd, featureId,entId, billType, lmId, lastModified, timeZoneId, customerId, and granularity.]
122 {field} is a required field and should have a not null value. [Note: This error code is applicable for the fields - Eid, namespaceName, featureName, startDate, endDate, userIds, featureId, productName, productVersion, detailsLM, lmId, templateType, customAttribute, lineItemId, customerRefId, granularity, loginId, oldPassword, and newPassword.]
132 The URL address does not exist.
519 Customer not found for the given customerId.
529 Given e-mail ID {actual Value} is not unique. Please try again with different ID.
1081 Invalid Web service version provided
1084 No Web service version provided
1088 The EMS system is running on HTTPS. Please provide the correct Web service URL.