getProfile

The getProfile method enables you to retrieve the profile and temporal information about the visitor visiting the touchpoint.

getProfile(String sessionID, NameValuePair[] parameters)
  • sessionID-a string identifying the session ID.
  • parameters - NameValuePair objects identifying any parameters that are required to be passed with the API request.

Return value

The runtime server responds to getProfile with a Response object with the following attributes populated:

  • AdvisoryMessages
  • ApiVersion
  • ProfileRecord
  • SessionID
  • StatusCode

Example

The following is an example of using getProfile and a way to handle the response.

sessionId is the same string to identify the session used by the startSession call which started this session.

response = api.getProfile(sessionId);
/**  Process the response appropriately */
    // check if response is successful or not
    if(response.getStatusCode() == Response.STATUS_SUCCESS)
    {
        System.out.println("getProfile call processed with no warnings or errors");
        // Print the profile - it's just an array of NameValuePair objects
        for(NameValuePair nvp : response.getProfileRecord())
        {
            System.out.println("Name:"+nvp.getName());
            if(nvp.getValueDataType().equals(NameValuePair.DATA_TYPE_DATETIME))
            {
                System.out.println("Value:"+nvp.getValueAsDate());
            }
            else if(nvp.getValueDataType().equals(NameValuePair.DATA_TYPE_NUMERIC))
            {
                System.out.println("Value:"+nvp.getValueAsNumeric());
            }
            else
            {
                System.out.println("Value:"+nvp.getValueAsString());
            }
        }
    }
    else if(response.getStatusCode() == Response.STATUS_WARNING)
    {
        System.out.println("getProfile call processed with a warning");
    }
    else
    {
        System.out.println("getProfile call processed with an error");
    }
    // For any non-successes, there should be advisory messages explaining why
    if(response.getStatusCode() != Response.STATUS_SUCCESS)
        printDetailMessageOfWarningOrError("getProfile",
			response.getAdvisoryMessages());