POST Data From Android Device

hello , I m interested to Upload my data via Rest api to the Local Server. but not getting how should i go ahead with this exactly. i have gone through the below links : 1)http://demo.openmrs.org/openmrs/module/webservices/rest/test.htm 2)http://localhost/openmrs/module/webservices/rest/apiDocs.htm#!/patient/createPatient. 3)https://wiki.openmrs.org/display/docs/REST+Web+Service+Resources+in+OpenMRS+1.9#RESTWebServiceResourcesinOpenMRS1.9-Patient

but I’m not getting how to upload data from device to Server by using Rest API’s.

@monicashityalkar, you may have to be more specific. Can you point us to the code you are using and tell us what you are expecting to happen and what is actually happening?

Does it work if you try to POST from the commandline using a command similar to the following?

curl -X POST -u admin:Admin123 -H "Content-Type: application/json" -d '{
  "person": {
    "names": [{
      "givenName": "Mittie",
      "familyName": "Davidson"
    }],
    "gender": "F"
  },
  "identifiers": [{
    "identifierType": "05a29f94-c0ed-11e2-94be-8c13b969e334",
    "identifier": "VCG4VJ293XP825WC80",
    "location": "8d6c993e-c2cc-11de-8d13-0010c6dffd0f"
  }]
}' "http://localhost:8080/openmrs/ws/rest/v1/patient"

Also, is there a reason you’re duplicating the work currently being done by @avijitghosh82 (as discussed here)?

Hey hello… I have gone through your reference code below. Thank you for your help. The part I was missing out was the appropriate header. And I didn’t wanted to duplicating the work by someone prior ; but I was stuck as in how to Post Data of Vitals using REST API’s . And I was not getting any relevant article which could explain me about this POST Vitals / Visits /Encounter with example from android device.

Thank you. Regards, Monica.

Vitals are usually captured as observations, so you’ll need to POST to the /obs resource. You can see some example values from the demo server at http://demo.openmrs.org/openmrs/ws/rest/v1/obs?patient=63baaa21-a9d5-405e-b0e9-d2c3c4ac2403.

The docs for the resources to create Visits and Encounters are:

Look at the OpenMRS Android Client for Android examples. Maybe start here, or if that isn’t useful it’s probably best to consult resources like stackoverflow.

Hello , I’m intrested to POST a json object for creating an Observation ; where ‘concept’, ‘person’ and ‘obsDateTime’ are mandatory fields. What should I send in ‘concept’ here . Below is the json I’m posting to upload Obs and the output of Concept that I got in GET concept by patient uuid. Thankful if anyone can help me with this. Is this the correct method to POST Observation? or should I POST whole VISIT/ENCOUNTER in whole as a body of my webservice ?

{[http://www.freeformatter.com/gfx/minus.gif] “concept”: " ? ", “obsDatetime”: “2016-06-17T20:04:49+05:30”, “person”: {[http://www.freeformatter.com/gfx/minus.gif] “names”: [[http://www.freeformatter.com/gfx/minus.gif] {[http://www.freeformatter.com/gfx/minus.gif] “givenName”: “Mittie”,

        "familyName": "Davidson"
     }
  ],
  "gender": "F"

} }

[cid:image003.jpg@01D1C8DD.728DFA90]

[cid:image005.jpg@01D1C8DD.728DFA90]

For concept you put the UUID of the OpenMRS concept. You can find this by querying the /concept resource, e.g.

curl -u admin:Admin123 'http://demo.openmrs.org/openmrs/ws/rest/v1/concept?q=weight'

gives

{
    "results": [{
        "uuid": "832AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
        "display": "Weight loss",
        "links": [{
            "rel": "self",
            "uri": "NEED-TO-CONFIGURE/ws/rest/v1/concept/832AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
        }]
    }, {
        "uuid": "5089AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
        "display": "Weight (kg)",
        "links": [{
            "rel": "self",
            "uri": "NEED-TO-CONFIGURE/ws/rest/v1/concept/5089AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
        }]
    }, {
        "uuid": "5090AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
        "display": "Height (cm)",
        "links": [{
            "rel": "self",
            "uri": "NEED-TO-CONFIGURE/ws/rest/v1/concept/5090AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
        }]
    }]
}

For person, you put the UUID of the person, which you can find in the same way:

curl -u admin:Admin123 'http://demo.openmrs.org/openmrs/ws/rest/v1/person?q=mary'

gives

{
    "results": [{
        "uuid": "a4ea2d4a-4a4f-4215-8fdf-ee4d26d4d82d",
        "display": "Mary Thomas",
        "links": [{
            "rel": "self",
            "uri": "NEED-TO-CONFIGURE/ws/rest/v1/person/a4ea2d4a-4a4f-4215-8fdf-ee4d26d4d82d"
        }]
    }, {
        "uuid": "41e84cf8-156f-466c-83ce-f34359d6b88f",
        "display": "Mary Pérez",
        "links": [{
            "rel": "self",
            "uri": "NEED-TO-CONFIGURE/ws/rest/v1/person/41e84cf8-156f-466c-83ce-f34359d6b88f"
        }]
    }, {
        "uuid": "cf0768ea-c304-4fbc-9f58-4a22e8333d0b",
        "display": "Mary Miller",
        "links": [{
            "rel": "self",
            "uri": "NEED-TO-CONFIGURE/ws/rest/v1/person/cf0768ea-c304-4fbc-9f58-4a22e8333d0b"
        }]
    }, {
        "uuid": "63baaa21-a9d5-405e-b0e9-d2c3c4ac2403",
        "display": "Mary Phillips",
        "links": [{
            "rel": "self",
            "uri": "NEED-TO-CONFIGURE/ws/rest/v1/person/63baaa21-a9d5-405e-b0e9-d2c3c4ac2403"
        }]
    }]
}

The obsDatetime is the date on which the observation was made. You also need to provide a value (which depends on the type of the concept). Read this and explore here to get an understanding of the OpenMRS data model.

So, if you want to capture Weight (kg) for Mary Thomas, you would do the following:

curl -X POST -u admin:Admin123 -H "Content-Type: application/json" - d '{
"concept": "5089AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"person": "a4ea2d4a-4a4f-4215-8fdf-ee4d26d4d82d",
"obsDatetime": "2016-06-17T20:04:49+05:30",
"value": 65
}' "http://demo.openmrs.org/openmrs/ws/rest/v1/obs"

hey thanks … I got now how the observation is send. But I want to create an Encounter. And for an Encounter I’m sending this above observation ref as you had previously given for Weight as “5089AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA” on similar basis i have saved one observation for height and wanted to save this observation in an Encounter as below

curl -X POST -u admin:Admin123 -H "Content-Type: application/json" - d '{
{
"obs": "ca98ff21-bb57-49aa-b538-a0b760df044f",
"patient": "936112d2-2988-465c-a4bb-557193545c58",
"encounterType" : "67a71486-1a54-468f-ac3e-7091a9a79584"
}' "http://demo.openmrs.org/openmrs/ws/rest/v1/encounter"

as i have

{
    "uuid": "67a71486-1a54-468f-ac3e-7091a9a79584",
    "display": "Vitals",
    "links": [{
        "rel": "self",
        "uri": "http://10.30.2.34:8080/openmrshttp://10.30.2.34:8080/openmrs/ws/rest/v1/encountertype/67a71486-1a54-468f-ac3e-7091a9a79584"
    }]
} 

for http://demo.openmrs.org/openmrs/ws/rest/v1/encountertype.

But I’m not able to save a Encounter in this way…it gives me Error as 400 bad request… It will be good if you can post some json example of Visit and Encounter both . Thank You.

What is in the body of 400 response? Can you see anything in the Tomcat logs?

HTTP/1.1 400 Bad Request Server: Apache-Coyote/1.1 Set-Cookie: JSESSIONID=9D873215D9A082AFA3967B19EBCD9F2D; Path=/openmrs/ Content-Type: application/json;charset=UTF-8 Content-Length: 8356 Date: Thu, 23 Jun 2016 14:50:33 GMT Connection: close

{“error”:{“message”:"[obs on class org.openmrs.Encounter]",“code”:“org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource:748”,“detail”:“org.openmrs.module.webservices.rest.web.response.ConversionException: obs on class org.openmrs.Encounter\r\n\tat org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource.setProperty(BaseDelegatingResource.java:748)\r\n\tat org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource.setConvertedProperties(BaseDelegatingResource.java:615)\r\n\tat org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource.create(DelegatingCrudResource.java:93)\r\n\tat org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceController.create(MainResourceController.java:91)\r\n\tat sun.reflect.GeneratedMethodAccessor1291.invoke(Unknown Source)\r\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\r\n\tat java.lang.reflect.Method.invoke(Method.java:498)\r\n\tat org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)\r\n\tat org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:440)\r\n\tat org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:428)\r\n\tat org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)\r\n\tat org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)\r\n\tat org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:953)\r\n\tat org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:855)\r\n\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:648)\r\n\tat org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:829)\r\n\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:729)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)\r\n\tat org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)\r\n\tat org.openmrs.module.web.filter.ForcePasswordChangeFilter.doFilter(ForcePasswordChangeFilter.java:61)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)\r\n\tat org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:72)\r\n\tat org.openmrs.web.filter.GZIPFilter.doFilterInternal(GZIPFilter.java:64)\r\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)\r\n\tat org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:70)\r\n\tat org.openmrs.module.webservices.rest.web.filter.AuthorizationFilter.doFilter(AuthorizationFilter.java:108)\r\n\tat org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:70)\r\n\tat org.springframework.web.filter.ShallowEtagHeaderFilter.doFilterInternal(ShallowEtagHeaderFilter.java:73)\r\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)\r\n\tat org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:70)\r\n\tat org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)\r\n\tat org.openmrs.module.logmanager.web.filter.RequestProviderFilter.doFilterInternal(RequestProviderFilter.java:36)\r\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)\r\n\tat org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:70)\r\n\tat org.openmrs.module.web.filter.ModuleFilter.doFilter(ModuleFilter.java:54)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)\r\n\tat org.openmrs.web.filter.OpenmrsFilter.doFilterInternal(OpenmrsFilter.java:109)\r\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)\r\n\tat org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:230)\r\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)\r\n\tat org.openmrs.web.filter.StartupFilter.doFilter(StartupFilter.java:105)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)\r\n\tat org.openmrs.web.filter.StartupFilter.doFilter(StartupFilter.java:105)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)\r\n\tat org.openmrs.web.filter.StartupFilter.doFilter(StartupFilter.java:105)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)\r\n\tat org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)\r\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)\r\n\tat org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)\r\n\tat org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)\r\n\tat org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)\r\n\tat org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)\r\n\tat org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)\r\n\tat org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)\r\n\tat org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)\r\n\tat org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522)\r\n\tat org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095)\r\n\tat org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)\r\n\tat org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1502)\r\n\tat org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1458)\r\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)\r\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)\r\n\tat org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)\r\n\tat java.lang.Thread.run(Thread.java:745)\r\nCaused by: org.openmrs.module.webservices.rest.web.response.ConversionException: Can only convert a Collection to a Collection/Array. Not class java.lang.String to java.util.Set<org.openmrs.Obs>\r\n\tat org.openmrs.module.webservices.rest.web.ConversionUtil.convert(ConversionUtil.java:185)\r\n\tat org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource.setProperty(BaseDelegatingResource.java:734)\r\n\t… 77 more\r\n”}}

Try to get an existing encounter from the API. That should give you a hint regarding what it should look like.

If i use GET by url http://10.30.2.34:8080/openmrs/ws/rest/v1/encounter?patient=936112d2-2988-465c-a4bb-557193545c58 what i get is this :

{
    "results": [{
        "uuid": "ca98ff21-bb57-49aa-b538-a0b760df044f",
        "display": "Vitals 23/06/2016",
        "links": [{
            "rel": "self",
            "uri": "http://10.30.2.34:8080/openmrshttp://10.30.2.34:8080/openmrs/ws/rest/v1/encounter/ca98ff21-bb57-49aa-b538-a0b760df044f"
        }]
    }, {
        "uuid": "c7f341c3-efb1-481d-8144-55403961475f",
        "display": "Vitals 23/06/2016",
        "links": [{
            "rel": "self",
            "uri": "http://10.30.2.34:8080/openmrshttp://10.30.2.34:8080/openmrs/ws/rest/v1/encounter/c7f341c3-efb1-481d-8144-55403961475f"
        }]
    }]
}

and if i skip obs in the ábove encounter

{
  "patient": "936112d2-2988-465c-a4bb-557193545c58",
  "encountertype" : "67a71486-1a54-468f-ac3e-7091a9a79584f"
}

my encounter is created but it doent have any observation …So there is nothing seen in Last Vitals tab…

this worked …

{
    "obs": [{
        "concept": "5089AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
        "person": "936112d2-2988-465c-a4bb-557193545c58",
        "obsDatetime": "2016-06-23T15:13:49+05:30",
        "value": 65
    }],
    "patient": "936112d2-2988-465c-a4bb-557193545c58",
    "encounterType": "67a71486-1a54-468f-ac3e-7091a9a79584"
}

but I’m sorry that I couldn’t found anything which would help me in RETRIEVING this Last CREATED ENCOUNTER As Last Updated VITALS of that patient .

i have created a VISIT using this… but these parameters are not seen in the latest Vitals :frowning: what must be the reason behind this…???

{
    "encounters": [{
        "obs": [{
            "concept": "5089AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
            "person": "936112d2-2988-465c-a4bb-557193545c58",
            "obsDatetime": "2016-06-23T15:13:49+05:30",
            "value": 65
        }],
        "patient": "936112d2-2988-465c-a4bb-557193545c58",
        "encounterType": "67a71486-1a54-468f-ac3e-7091a9a79584"
    }],
    "patient": "936112d2-2988-465c-a4bb-557193545c58",
    "visitType": "7b0f5697-27e3-40c4-8bae-f4049abfb4ed"
}

Hey , When I POST any Visit it gets Uploaded properly ; but I ‘m not able to see these Visit’s Vitals as the last Updated Vitals . Also when I click on this link ( UI ) on the Server for Edit it gives me Error as encounter.form is null. I’m not getting in which format am I supposed to POST a visit from my Android Device .

And FormEntryActivity.java do have something as

              new FormsManager().uploadXFormWithMultiPartRequest(
    FormsHelper.createUploadXFormWithMultiPartRequestListener(bundle));

which I’m not able to understand.

Hope that someone helps me. Thank you .

[cid:image002.jpg@01D1D0A6.A5545110]

I don’t think this is possible. Based on the SearchHandler, it looks like you’ll have to search by encounterType and patient and sort the results yourself.[quote=“monicashityalkar, post:14, topic:6776”] when I click on this link ( UI ) on the Server for Edit it gives me Error as encounter.form is null [/quote]

Are you setting the form for the encounter? If not, you could try to do that by using the uuid for the Vitals form (found here). This is what the complete encounter should look like once correctly created.

@pascal :Thanks a lot !! yes my Form field was missing in Encounter creation. But want to ask that even though giving

{
    "obsDatetime": "2016-06-27T15:13:49+05:30",
    "encounterDatetime": "2016-06-27T15:13:49+05:30",
    "startDatetime": "2016-06-27T15:13:49+05:30"
}

but still when i click on this UI it gives me : UI Framework Error Root Error java.lang.IllegalArgumentException: The date must not be null ** at org.apache.commons.lang.time.DateUtils.add(DateUtils.java:414)** ** at org.apache.commons.lang.time.DateUtils.addDays(DateUtils.java:341)** ** at org.apache.commons.lang.time.DateUtils$addDays.call(Unknown Source)** ** at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)** ** at org.apache.commons.lang.time.DateUtils$addDays.call(Unknown Source)** _** at SimpleTemplateScript25$run_closure4.doCall(SimpleTemplateScript25.groovy:108)** ** at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)** ** at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)** ** at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)** ** at java.lang.reflect.Method.invoke(Method.java:498)** ** at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:88)** ** at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)** … "

i have compared the json of both the fields there is no difference in both the visits created manually and by WebService. what must i may be missing then ?

Can you paste the steps required to reproduce this error against the demo or uat server, including the Curl command used to make the REST call?

Try to have a look at the complete encounter you created via REST and compare it with one successfully created via the UI. Make sure there are no differences.

Are you sure there is no difference between the JSON returned by:

GET http://yourserver/openmrs/ws/rest/v1/encounter/uuid-for-rest?v=full

and

GET http://yourserver/openmrs/ws/rest/v1/encounter/uuid-for-ui?v=full

OpenMRS Talk (Discourse) uses Common Markdown to format posts. You can find a very basic introduction on that here.

curl -X POST -u admin:Admin123 -H "Content-Type: application/json" - d '
{
    "encounters": [{
        "obs": [{
            "concept": "5089AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
            "person": "deb0905c-3b82-4631-88b2-b71425755cdf",
            "obsDatetime": "2016-06-27T15:13:49+05:30",
            "value": 65
        }],
        "patient": "deb0905c-3b82-4631-88b2-b71425755cdf",
        "encounterType": "67a71486-1a54-468f-ac3e-7091a9a79584",
 "encounterDatetime": "2016-06-27T15:13:49+05:30",
"form" :"a000cb34-9ec1-4344-a1c8-f692232f6edd"
    }],
    "patient": "deb0905c-3b82-4631-88b2-b71425755cdf",
    "visitType": "7b0f5697-27e3-40c4-8bae-f4049abfb4ed",
"location" : "b1a8b05e-3542-4037-bbd3-998ee9c40574",
 "startDatetime": "2016-06-27T15:13:49+05:30"
}' "http://demo.openmrs.org/openmrs/ws/rest/v1/visit"

Error is as follows if i click here : UI Framework Error Root Error java.lang.IllegalArgumentException: The date must not be null ** at org.apache.commons.lang.time.DateUtils.add(DateUtils.java:414)**

Steps to get above Error are :
1)POST a visit by the above statement through WebService 2)Now click this visit’s UI you may get immediately the above Error.

Based on this line in the stack trace:

Caused by: org.openmrs.ui.framework.FragmentException: Error evaluating view: patientdashboard/visits

The error appears to be happening in the visits.gsp file. I tried to find any differences between a visit that works (that was created via the UI) and one created via REST, but I couldn’t see any significant difference. I didn’t look in the database though.

Based on this section of the stack trace:

java.lang.IllegalArgumentException: The date must not be null
	at org.apache.commons.lang.time.DateUtils.add(DateUtils.java:414)
	at org.apache.commons.lang.time.DateUtils.addDays(DateUtils.java:341)

I suspect the issue is with line 90 or line 92. I’m not too familiar with that code unfortunately, but perhaps @darius, @wyclif or @raff might easily be able to spot the issue.

For now, I’d recommend that you look closely at the database and try to identify any differences between visits created via the UI and those created via REST. This could be a bug, so anything you manage to find out could be useful in resolving the issue.

Sorry I can’t be more helpful right now.

@pascal hello I have seen the database and the things that i observed were as follows :

  1. the stopDatetime field was null ; when i passed this attribute too ;it worked and i didnt gt any such DateUtils Error.

Thank you.