Please join your peers on either March 26 (8pm GMT) or March 28 (8am GMT) to watch as user extraordinaire and forum legend @"lindsay.stevens" demonstrates OpenClinica Insight.

See preview and register at

Insight makes it easy to ask questions of ALL of your clinical and operational data and visualize answers via interactive reports and dashboards. The idea is simple, but the results are powerful: ask your questions, choose your visualizations, then return often for updated, interactive results that link you to all of the underlying data.

Creating study using REST API

I am trying to create a study using REST API. But, it shows 401 Bad credentials error with a description as this request requires HTTP authentication.

I set API key of a user to api_key in the header of the URL. Is there any other authentication is required?
And how to remove this error.



  • GerbenRienkGerbenRienk Posts: 765 ✭✭✭
    Hi Abhit,
    Did you encode it Base64?
    Kind regards,
    Gerben Rienk
  • abhijitgosaviabhijitgosavi Posts: 8
    Hi GerbenRienk,
    No. I am not encoding key to Base64. Does it need?

  • GerbenRienkGerbenRienk Posts: 765 ✭✭✭
    Yes, I'm afraid that's required. In most cases you would take
    and encode that to use in the header, but with this rest-api you must use only
    and encode that.
  • abhijitgosaviabhijitgosavi Posts: 8
    I encode API-key to base64. But it shows 500 Internal Server Error.
    I am not getting what actually error is. Please suggest solving this error and how to create study successfully.
  • GerbenRienkGerbenRienk Posts: 765 ✭✭✭
    Hi Abhijit,
    That's good: you're one step further. It means that the server is trying to rocess the request, but something went wrong. Did you look in the logs?
    And can you share the api you are sending the request to plus the parameters? Then we can have a look.
    Kind regards,
    Gerben Rienk
  • abhijitgosaviabhijitgosavi Posts: 8
    I check in logs but it shows the same error 500 internal server error.
    Post API : http://localhost:8080/OpenClinica/pages/auth/api/v1/studies/
    Header : api_key: YzhhODI1NDUxMDRlNGZkODk5Mzg2NTBmYTcwZGJkMjM=
    Parameters :
    "briefTitle": "Experimental new Study",
    "principalInvestigator": "default",
    "expectedTotalEnrollment": "10",
    "sponsor": "n_a",
    "protocolType": "Interventional",
    "status": "available",
    "assignUserRoles": [
    { "username": "usera", "role": "Data Manager" }
    "uniqueProtocolID": "TES003",
    "briefSummary": "Study for post api",
    "startDate": "2017-05-12"

  • GerbenRienkGerbenRienk Posts: 765 ✭✭✭
    Hi Abhijit,
    How strange: I can create a study with these same parameters, except for the user-account:

    Which version of OpenClinica do you use?
    Gerben Rienk
  • jguptajgupta Posts: 27
    Here is a document I created for Rest API training, hope this is helpful. Please follow step by step instruction as demonstrated.
    Best regards,
  • abhijitgosaviabhijitgosavi Posts: 8
    Thanks! Gerben and jigyasa for your help with this.
    Can we upload CRF using Rest API? Is there any API for CRF upload?

    Best regards,
Sign In or Register to comment.