How to add new property in Openmrs Rest API [Solved]

Hello there, I am trying to add new property called image in location table to give logo to each location. I have added a column in location table and declared it in openmrs api . Data for respective image is coming from database but its not returning the image in response of api. I am new to hibernate ORM i also mapped the property for logo but didn’t getting it in api response.

end point that I am hitting http://localhost:8080/openmrs/ws/rest/v1/location Thanks in Advance.

@atiq , after adjusting the Location Model , you would also make a coresponding change in the Location Resource in the Rest API , but in the submodule coressponding to the OpenMRS version youre running. you would have to add the new property in the Location Resource

2 Likes

Hi @mozzy desperately waited for response. Appreciate ! ! I am using core 2.3.2 I will do the changes and revert back the outcome with you Thanks A lot :smiley:

1 Like

Actually , simply add your property here , in the Location Resource Class for omod-2.0

this resource class supports up to OpenMRS 2.5

1 Like

Actually I am running 2.29.0 for web rest I couldn’t find Location Resource at there

clone this repo GitHub - openmrs/openmrs-module-webservices.rest: Provides RESTful web services for OpenMRS and add your changes then build and deploy the module and run again

Ok actually i was searching in 2.29.0 branch in tags. I will follow as you suggest. Thanks.

well even under the 2.29.0 tag , its here

1 Like

Hello @mozzy I am getting this error after buid is kind of error related to latitude but i haven’t done any changes in latitude. here is the error

can i have a look at your changes in github ??

1 Like

can i also look at your property in the Location Class ??

1 Like

from the Logs , Looks like theres a mismatch between the property you added in the Rest Module and what exactly you added in the Location Class

1 Like

Hey @mozzy I just created repo and pushed the code for core only. Please check my changes here

Changes what i did in webrest module.

Better if you had just Forked the source code from OpenMRS repo to Your repo and then add your changes. It becomes easy and direct to track the changes you added

1 Like

Ok will do the same. Thanks

did you add the coresponding column in the hibernate mappings for the property ??

Yes I did I am sharing direct path to location.hbm

please check.

Hey @mozzy Sorry my bad there will be accidental mistake in locationId replaced with latitude. in hibernate mapping.

cool , does it work fine now ??

1 Like