You are here: Catalog Elements > Product > getProductByNameAndVer

Retrieve Product Details By Name and Version

Description

Retrieve product details for the given product name and version.

Default Protocol Method Type URI
HTTPS GET getProductByNameAndVer.xml

Query Parameters

Parameter Description Valid Values Optional
productName Specify the product name. String No
productVersion Version of the product. 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 getProductByNameAndVer.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/getProductByNameAndVer.xml");
                query = new StringBuffer();
                setParameter("productVersion", "");
                setParameter("productName", "");
                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>
   <product>
      <creationTime>1426137147000</creationTime>
      <deployed>true</deployed>
      <desc />
      <features>
         <feature>
            <id>25</id>
            <name>25</name>
            <ver />
         </feature>
      </features>
      <id>3</id>
      <lifeCycleStage>Complete</lifeCycleStage>
      <modificationTime>1426139580000</modificationTime>
      <name>Pnew</name>
      <namespaceId>1</namespaceId>
      <namespaceName>test36</namespaceName>
      <refId1 />
      <refId2 />
      <saId>1</saId>
      <ver>3</ver>
   </product>
   <stat>ok</stat>
</emsResponse>
See Also:

Output Format for Failure

Error Codes

Error Code Description
100 Invalid request parameter.
102 Invalid data entered.
107 An internal error occurred! Please report the error to System administrator.
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.
133 Invalid namespace.
1029 Product does not exist for the given name and version.
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.