You are here: Customers and Contacts > getCustomerByCustomerName

Retrieve Customer Details by Name

Description

Retrieve details of a customer using exact customer name.

Default Protocol Method Type URI
HTTPS GET getCustomerByCustomerName.xml

Query Parameters

Parameter Description Valid Values Optional
customerName Specify the customer name. String No

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 getCustomerByCustomerName.xml()throws Exception {
                if(!verifyLogin()){
                        return "login failed";
                }
                HttpContext context = new BasicHttpContext();
                context.setAttribute(ClientContext.USER_TOKEN, principal);
                HttpGet get = new HttpGet("https://localhost:8080/ems/3.6/getCustomerByCustomerName.xml");
                query = new StringBuffer();
                setParameter("customerName", "");
                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

<emsResponse>
  <customers>
    <customer>
      <contacts>
        <contact>
          <admin>false</admin>
          <contactEmail>alaska@alaska.com</contactEmail>
          <contactId>1</contactId>
          <contactName>alaska</contactName>
          <contactNumber />
          <creationTime>1334808889000</creationTime>
          <customerName>Alaska</customerName>
          <modificationTime>1334808889000</modificationTime>
          <status>true</status>
        </contact>
      </contacts>
      <creationTime>1334808889000</creationTime>
      <customerId>1</customerId>
      <customerName>Alaska</customerName>
      <customerRefId>alaska</customerRefId>
      <desc />
      <enabled>true</enabled>
      <modificationTime>1334808889000</modificationTime>
      <refId />
      <timezone>(GMT-09:00) Alaska</timezone>
    </customer>
  </customers>
  <stat>ok</stat>
  <total>1</total>
</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.
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.]
128 You should log on first.
132 The URL address does not exist.
512 The customer does not exist.
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.