Creating complex observations via the REST API

I’m having problems creating complex observations via the REST API and wondered if someone could give me some pointers.

Simply submitting something like:

{ “obsDatetime”: “2014-03-15”, “concept”: “919002a0-7156-459c-b43e-013817f45a50”, “value”: “Some sample data”, “person”: “ef047660-c683-11e4-aca6-017136ba04e3” }

where the concept is a complex datatype with a texthandler or binarydatahandler results in an error like this:

{ “error”: { “message”: “Unable to convert object into response content”, “code”: “”, “detail”: " value on class org.openmrs.Obs\n\tat …

I can create obs with simple datatypes without problems, but there’s not much in the way of documentation or example code that I’ve been able to find regarding complex types.

My aim is to create an observation which is basically a blob of json data. This is then interpreted by front end javascript to produce diagrams.

Regards, Jamie Neil

Obviously not the right forum for questions like this given the lack of response. I will repost elsewhere.

In case anyone is interested, I have got as far as working out that the REST API seems to be only able to cope with either strings (or numbers cast to strings) or coded values. Strings are passed through to the Obs class in core and then fail due to the fact that it’s setValueAsString function has no way of handling complex values.

Hi @jam13 … this is probably best suited for the OpenMRS Developers mailing list. For details on how to subscribe and send a message, see:

Hi Michael,

Thanks for responding. I posted the question to the developers mailing list earlier today, so I’ll wait to see if I get any takers there.

Regards, Jamie

1 Like