Attachments: Rest API Swagger


I need to add attachment via API, but unfortunately I can’t find input structure documentation. My local install version of OpenMRS and online demo version both don’t have description for that on API documentation page because of errors during page loading

Thank you.

Is this the link you are following, Again could you add more of information, what are you trying to do

I’m trying to find info about JSON input structure for adding/updating attachments via API.

Did you got a chance looking at Openmrs rest for clients . Another thing is that if may be if you want to get attachment calls via api, then the url shall go like depending your need.

The API docs page is missing info about JSON structure for creating attachment. I just need to know what exact structure must have JSON in the body of creation request. Something like { ‘Id’, ‘aaaa-aaaa-aaaa-aaaa’, ‘Name’, ‘Filename/pdf’, Content, ‘FileBitesHereAsBase64’ }

Something like this is explained more with in this link, did you take a look into it please

POST /openmrs/ws/rest/v1/person/:target_person_uuid/name


"givenName" : "John" ,

"familyName" : "Smith"


Yes, and I need to know what exact fields must be in the JSON for adding new attachment.

Are you familiar with using post man client, If you want to query any data from database using rest , You call some end points like i said before.

POST /openmrs/ws/rest/v1/person/:target_person_uuid/name


`` "givenName" : "John" ,

`` "familyName" : "Smith"

} This is an example of post call

Yes, I know it all. I just need fields list for the JSON.

hello @mksd could we be having a rest api json structure for attachment resource ,i have looked into the openmrs swagger specs of attachment but no resource body. The properties i see defined here in the attachment resource

Requesting for your thought on this

@amalukov The json structure can be derived by looking at some of the tests in the module…for example Add these four parameters… unfortunately can’t give u json structure coz am currently replying on phone but I hope that gives u what u need

@amalukov can you have a look at this Create Complex Obs with REST API [SOLVED] since an attachment is a complex obs added to a patient info

1 Like

@gcliff what does it take to ensure that Attachments is documented by Swagger? That’d be the way to go.

1 Like

Thats a good point @mksd , we can go ahead and document it, @gcliff are you available for this or i can volunteer?

Thank you for the answers. I will try to use unit tests to figure out attachments creating JSON structure.

1 Like

Hello @mksd sorry for the delayed response ,i was away for the most part of yesterday…

For a resouce to be documented it has to override 1. Model getGETModel(Representation) 2. Model getCREATEModel(Representation)
3. Model getUPDATEModel(Representation)

i have created card to implement this


Hello i created a draft PR here but am blocked with invalidActivationKeyException. according to openmrs api here, it seems this exception is old exception and its nolonger used. kindly guide me cc @mksd @dkayiwa @ibacher @reagan @gcliff thanks

Hello There, I want to know where these uploaded attachments gets stored. In server side directory or in the database. Because I want to list all the attachments associated with the patients. Thank You.

There are stored both in the database and can be easily rendered/retrieved via rest api using swagger and sample swagger api

1 Like

@atiq does this give you an insight on how these are saved openmrs-module-attachments/ at 6970a7cc4792c5a323be936f2aa271893bc97e8c · openmrs/openmrs-module-attachments · GitHub

1 Like