Image Upload using rest API

Hello Friends,

I am a new user. Want to upload image using Rest API. I want to upload image with obs. Please help me.


As the first step, can you first of all ensure that you can save one from the user interface using this documentation?

Thanks Daniel, I am able to upload & display image using compex context in obs using user interface. But I am not getting any way to retrieve this image using rest api ? Also how an image will be upload using rest API.


Hi @brai17,

The ObsResource now handles complex data (such as image files) via REST. This has been developed recently and the only examples that I can find are the unit tests covering the new feature. You can either wire the files as Base64 encoded within the JSON requests/responses or alongside the JSON data as byte arrays (so raw files basically).

As a side note, VDUI is not yet 100% REST compliant, so you will have to wait a little before you can GET and POST images entirely through it via REST. But otherwise, it already provides web endpoints to save and fetch any files (including images of course). Making it entirely REST compliant is on its roadmap but work on it hasn’t started yet. However that could happen before October if it becomes part of Ref App 2.7.

Hi @dkayiwa, @mksd,

I found if a image or document is uploaded to obs using complex concept. Uploaded image is stored in openmrs application data directory and openmrs database only stored image name. So when it is displaying image on user interface then it reads image from application data directory and show in user interface.

I deployed openmrs war in my tomcat and my application is interacting with openmrs with rest api only. My question is how I can upload image using rest API and how I can get back using rest API. Another question is can I use S3 to upload documents. is there any configuration to use s3 with OpenMRS.

Please help!!

Hi @brai17,

See my last post regarding using a REST endpoint with complex obs.