Skip to main content
Content Starts Here

We've Moved!

Please note that we have moved to our New Forum site.


Ask Search:
Oskar KaverOskar Kaver 

Contact Platform SDK

Hi,

I was wondering if someone could provide a complete java example to request a contact from the contact SDK based on the contact ID?
It seems to me a bit tedious to search based on search values when we have the id, and there is also multiple different methods that may be used as far as I understand (RequestContactListGet, RequestGetContacts, RequestIdentifyContact, RequestSearch), so which one is most suitable when I already have the contact id and just want to fetch the whole contact? 

BR
Oskar
 
Best Answer chosen by Oskar Kaver
Andrew BudwillAndrew Budwill
I believe you want RequestGetAttributes from PSDK, here is a dirty sample that I pieced together from some of my old code that you can re-purpose appropriately:
 
import com.genesyslab.platform.commons.protocol.Endpoint;
import com.genesyslab.platform.commons.protocol.Message;
import com.genesyslab.platform.contacts.protocol.UniversalContactServerProtocol;
import com.genesyslab.platform.contacts.protocol.contactserver.events.EventGetAttributes;
import com.genesyslab.platform.contacts.protocol.contactserver.requests.RequestGetAttributes;

public class UCSSample {

    private Endpoint ucsEndpoint;
    private String serverName;
    private int serverPort;
    private String clientName;
    private UniversalContactServerProtocol ucsConnection;
    
    public static void main(String[] args)
    {        
        new UCSSample();
    }
    
    public UCSSample()
    {
        serverName = "UCS_HOST_NAME";
        serverPort = 7000;
        clientName = "Some UCS Client";
        
        ucsEndpoint = new Endpoint(serverName, serverPort);
        ucsConnection = new UniversalContactServerProtocol(ucsEndpoint);
        ucsConnection.setClientName(clientName);
        
        try
        {
            ucsConnection.open();
            
            RequestGetAttributes request = new RequestGetAttributes();            
            request.setContactId("0000Pa9GCQPK1G0G");
                        
            Message response = null;            
            response = ucsConnection.request(request);
            
            if(response instanceof com.genesyslab.platform.contacts.protocol.contactserver.events.EventError)            
                System.out.println(response.toString());            
                        
            EventGetAttributes attributes = (EventGetAttributes)response;            
            System.out.println(attributes.toString());
            
            
        } catch (Exception ex)
        {
            ex.printStackTrace();
            System.exit(-1);
        }
        finally
        {
            try { ucsConnection.close(); } catch (Exception ex) { }
        }
        
    }
}

 

All Answers

Andrew BudwillAndrew Budwill
I believe you want RequestGetAttributes from PSDK, here is a dirty sample that I pieced together from some of my old code that you can re-purpose appropriately:
 
import com.genesyslab.platform.commons.protocol.Endpoint;
import com.genesyslab.platform.commons.protocol.Message;
import com.genesyslab.platform.contacts.protocol.UniversalContactServerProtocol;
import com.genesyslab.platform.contacts.protocol.contactserver.events.EventGetAttributes;
import com.genesyslab.platform.contacts.protocol.contactserver.requests.RequestGetAttributes;

public class UCSSample {

    private Endpoint ucsEndpoint;
    private String serverName;
    private int serverPort;
    private String clientName;
    private UniversalContactServerProtocol ucsConnection;
    
    public static void main(String[] args)
    {        
        new UCSSample();
    }
    
    public UCSSample()
    {
        serverName = "UCS_HOST_NAME";
        serverPort = 7000;
        clientName = "Some UCS Client";
        
        ucsEndpoint = new Endpoint(serverName, serverPort);
        ucsConnection = new UniversalContactServerProtocol(ucsEndpoint);
        ucsConnection.setClientName(clientName);
        
        try
        {
            ucsConnection.open();
            
            RequestGetAttributes request = new RequestGetAttributes();            
            request.setContactId("0000Pa9GCQPK1G0G");
                        
            Message response = null;            
            response = ucsConnection.request(request);
            
            if(response instanceof com.genesyslab.platform.contacts.protocol.contactserver.events.EventError)            
                System.out.println(response.toString());            
                        
            EventGetAttributes attributes = (EventGetAttributes)response;            
            System.out.println(attributes.toString());
            
            
        } catch (Exception ex)
        {
            ex.printStackTrace();
            System.exit(-1);
        }
        finally
        {
            try { ucsConnection.close(); } catch (Exception ex) { }
        }
        
    }
}

 
This was selected as the best answer
Oskar KaverOskar Kaver
Perfect. Thank you!!