Adding an observation using RESTful webservices

0 views
Skip to first unread message

M. Mahdi Mahdavi Amjad

unread,
Jun 2, 2013, 6:52:58 PM6/2/13
to implem...@openmrs.org
Hi,
I want to add an observation using the RESTful web service but I get HTTP error 500. This is my Java code:

public static void main(String[] args) throws Exception
{
ApiAuthRest.setUsername("user");
ApiAuthRest.setPassword("pass");
JSONObject jsonObj = new JSONObject();
jsonObj.put("person", "626bd0b6-13db-4cb3-a513-60eaba501e27");
jsonObj.put("obsDatetime", "2012-12-02T22:35:03");
jsonObj.put("concept", "be4f67b0-1691-11df-97a5-7038c432aabf");

//jsonObj.put("location", "8d6c993e-c2cc-11de-8d13-0010c6dffd0f");
//jsonObj.put("encounter", "48851");
//jsonObj.put("value", "98");
System.out.print(jsonObj.toString());
StringEntity inputAddPerson = new StringEntity(jsonObj.toString(), HTTP.UTF_8);
inputAddPerson.setContentType("application/json");
System.out.println("AddObs = " + ApiAuthRest.getRequestPost("obs",inputAddPerson));
System.out.println("########################");
}

I use the same code for adding person, patient and location. and it works.
BTW I think the format of the obsDatetime is not correct. Any suggestion?

Darius Jazayeri

unread,
Jun 2, 2013, 10:29:16 PM6/2/13
to implementers

Does the 500 error give any details? (It should...)

-Darius (by phone)

--
OpenMRS Implementers: http://go.openmrs.org/implementers
Post: implem...@openmrs.org
Unsubscribe: implementers...@openmrs.org
Manage your OpenMRS subscriptions at https://id.openmrs.org/
 
 
Reply all
Reply to author
Forward
0 new messages