• FEATURES
  • PRICING
  • MARKETPLACE
  • CASE STUDIES
  • BLOG
  • OpenSpecimen Forums

    REST API for registering participant to a Protocol

    Posting on behalf of Jianmin @ UNMC:

    I check the REST API for creation of participant and found there is no option to register the participant to collection protocols. If there is a REST API to register a participant to multiple collection protocols, it will be great. Or else we still need to use caTissue client API.
     
    It seems that after upgrading to openspecimen, the old caTissue API does not work anymore.

    Regards,
    Jianmin Feng

    Hi Jianmin,

    The REST API for registering participant to a Collection Protocol is available. The API documentation is available at https://catissueplus.atlassian.net/wiki/display/CAT/Create+Registration.

    However the current REST API implementation doesn’t support the registration of participant to multiple Protocols in single call. To register a participant to multiple Protocols, you need to call this API for each Protocol.

    ~Nitesh

    Nitesh,

    Do you have sample code for REST testing?

    If we do not have idap authentication, do I have to create our own authentication implementation?

    Thanks,
    Jayjay

    Hi @jmfeng,

    The REST API’s are language independent. You can call/test them using any programming language like JAVA, PHP, PERL etc.

    For your reference, I have attached one sample JAVA program, which simply creates the participant in the OpenSpecimen application. In this you just need to change the application URL, username, password. You can download the sample JAVA program here.

    Also there is one UI tool available to test the REST API’s.This is google chrome extension named “Advanced REST client”. You can download it here.

    ~Nitesh

    Nitesh,

    I finally got time to test the java code to consume the openspecimen webservice. I checked your sample code which using http. Our openspecimen is deployed using Https. Could you please post the testing code that using https?

    Thanks,
    jayjay

    get matching participant gives error 500,

    “The server has encountered a severe error.  Please try again.”

    WebResource service = client.resource(getBaseURI() + “/participants/matchParticipants”);
    try {
          response = service.type(MediaType.APPLICATION_JSON).post(ClientResponse.class, objectToBeMatched);
    }

    Any suggestion?

    Thanks,

    Hi @jmfeng,

    Apologize for the the delayed response.
    To access the rest API’s for https, you need to include the below code in the client:

       SSLContext ctx=null;
    try {
        KeyStore trustStore;
        trustStore = KeyStore.getInstance("JKS");
        trustStore.load(new FileInputStream("path to certificate"),"passphrase for the certificate".toCharArray());
        TrustManagerFactory tmf=TrustManagerFactory.getInstance("SunX509");
        tmf.init(trustStore);
        ctx = SSLContext.getInstance("SSL");
        ctx.init(null, tmf.getTrustManagers(), null);
    } catch (Exception e1) {
        e.printStackTrace();
    }
    ClientConfig config=new DefaultClientConfig();
    config.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, new HTTPSProperties(null,ctx));
    
    WebResource service=Client.create(config).resource("https://localhost:8443/");
    

    ~Nitesh

    Nitesh,

    Have you ever used pl/sql to call Openspecimen REST service? Or do you known anyone has done it?

    I am trying to call os rest api through pl/sql over https. But I met a problem with setup of https connection. I am using oracle 11gr2.

    Thanks,
    JJ