• FEATURES
  • PRICING
  • MARKETPLACE
  • CASE STUDIES
  • BLOG
  • Anyone has successfuly used REST API to create the participant protocol registration?

    I am trying to create the participant and register it with a protocol. I am using java. Our openspecimen was deployed to a testing server using HTTPS. We could not move to the production because the java api we used to create participant in catissueplus does not work with openspecimen. So I am testing to REST api for openspecimen.

    Up to now I could

    1. connect to the Https REST server
    2. create participant.

    The problems now:

    1. I failed to matching the existing participant, I think I could work round it by querying the database directly instead of using REST API.
    2. I failed to create participant registration with protocol, the error is 400, “request sent by the client was syntactically incorrect”. I think the problem is how to pass the participant details. Should it be the participant object?

    I created the class for participant registration:

    public class ParticipantRegistration {
        private ParticipantDetail participantDetail; //this is the object used to create participant
        private String cpId;
        private String ppId;
        private String barcode;
        private String activityStatus;
        private Date registrationDate;
        private Long id;
    }

    here is the code for creating registration:

    ClientResponse response = null;
    WebResource service = client.resource(getBaseURI() + “/collection-protocols/”+cpID+“registrations”);
    try {
             response = service.type(MediaType.APPLICATION_JSON).post(ClientResponse.class, PartRegObjToBeRegistered);
             System.out.println(response.getStatus()); // now the error is 400
    }

    here is the error in log of openspecimen server:
    ERROR 2014-11-05 15:59:13,909 dao.connectionmanager.DataSourceConnectionManager - dao.method.without.implementation

    I appreciate any suggestions.

    Regards,
    JJ

    Hi @jmfeng,

    1. The older caTissue API will work in OpenSpecimen-v1.0. There is no change in the APIs, but some domain objects got changed in OS-v1.0. This might require some changes in the older APIs you have written. For that, you need to update the catissuecore.jar which is attached catissuecore.jar (951.2 KB).
    2. Register Participant API: The URL you are using is wrong which is causing the 400 error. The URL you used is missing “/” after cpID. Use the below code and it will solve the issue.
      WebResource service = client.resource(getBaseURI() + “/collection-protocols/”+cpID+"/registrations");

    ~Nitesh

    Thanks Nitesh,

    it is the same error with the /.

    url first part: https://biotest.unmc.edu:443/openspecimen/rest/ng
    second part: /collection-protocols/181/registrations

    The error is the same:

    error in java : 400, The request sent by the client was syntactically incorrect.

    error in server: dao.connectionmanager.DataSourceConnectionManager - dao.method.without.implementation

    JJ

    Hi @jmfeng,

    I have shared a working JAVA client which registers participant to given CollectionProtocol. You can download the client here. I have tested this client locally as well as on our demo site. Its working fine and successfully registering the given participant.

    ~Nitesh

    I checked you code which is exactly what I did. Could you confirm that you are using the openspecimen v1.0.

    Yes, this sample code has been tested on OpenSpecimen-v1.0.

    ~Nitesh

    Thanks Nitesh, I finally go through it.

    This is a very attribute name of “ppid”, in your testing code, it is small letter “i”, In my code I used capital letter “I”. When I switch it to the lower case, it magically go through.

    I assume the attribute name should be exactly as specified as in REST api. in Json format input, it is case sensitive. This small trick cost me 3 days.

    thanks a lot.

    JJ