You are here: Customers and Contacts > searchContacts

Search Contacts

Description

Search contacts for the given query parameters.

Default Protocol Method Type URI
HTTPS GET searchContacts.xml

Query Parameters

Parameter Description Valid Values Optional
customerId The unique record ID of the customer in EMS database. Integer Yes
emailId E-mail address of a customer's contact String Yes
pageIndex The starting page number.

Integer (>0)

Yes
pageSize

The number of contacts retrieved by one request.

Its default value can be configured from EMS Admin Console by using the Max Records Per Response (Web Services) property.

Integer (>0)

Yes
sortCol Sort against the column.

String (contactName,emailId,customerName,id)

Default Value: id

Yes
sortOrder The order to sort.

String (asc, desc)

Default Value:desc

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 java.net.URLDecoder;

//..............................
//..............................
//..............................
import org.apache.http.params.HttpParams;
public class EMSSample {
                private static DefaultHttpClient httpclient = new DefaultHttpClient();
                private static Principal principal = null;
                private static StringBuffer query;
                //..............................
                //..............................
                //..............................
public static String searchContacts.xml()throws Exception  {
    if(!verifyLogin()){
                return "login failed";
    }
    HttpContext context = new BasicHttpContext();
    context.setAttribute(ClientContext.USER_TOKEN, principal);
         HttpGet get = new HttpGet("https://localhost:8443/ems/searchContacts.xml");
    query = new StringBuffer();
    setParameter("emailId", "");
    setParameter("refId2", "");
    setParameter("customerId", "");
    setParameter("refId1", "");
    setParameter("sortOrder", "");
    setParameter("pageSize", "");
    setParameter("sortCol", "");
    setParameter("pageIndex", "");
    get.setURI(new URI(URLDecoder.decode(get.getURI() + query.toString(),"UTF-8")));
    HttpResponse response = httpclient.execute(get, 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);
                }
    static void setParameter(String key, String value) {
                if (query.toString().equals("")) {
                                query.append("?" + key + "=" + value + "&");
                } else {
                                query.append(key + "=" + value + "&");
                }
    }
    }

Sample Response

<?xml version="1.0" encoding="UTF-8"?>
<emsResponse>
   <contacts>
      <contact>
         <admin>false</admin>
         <contNumber />
         <contactid>1</contactid>
         <contactname />
         <createDate />
         <creationTime>2015-03-09 04:48:19.0</creationTime>
         <customerId>1</customerId>
         <customername>c1</customername>
         <emailid>c1@s.com</emailid>
         <entitlementCount>4</entitlementCount>
         <lastModifiedTime>2015-03-09 04:48:19.0</lastModifiedTime>
         <refId1 />
         <refId2 />
         <status>true</status>
         <userRegistered />
      </contact>
   </contacts>
   <stat>ok</stat>
   <total>1</total>
</emsResponse>
See Also:

Output Format for Failure

Error Codes

Error Code Description
109 The sort order value is not valid. Specify asc or desc.
110 The page index value is not valid. Specify any positive integer value greater than 0.
111 The page size value is not valid. Specify any positive integer value greater than 0.
118 {field} should be of data type integer. [Note: This error code is applicable for the fields - featureId, License modelId, entId, ftrId, customerId, lmId, templateType, lineItemId, CustomerId, stationCount, status, and granularity.]
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.]
124 Invalid sortColumn. Valid values are startdate, enddate, state, status, contactemailid, customername, id.
128 You should log on first.
513 The contact does not exist.
519 Customer not found for the given customerId.