org.openmrs.api.APIException: A user context must first be passed to setUserContext()...use Context.openSession() (and closeSession() to prevent memory leaks!) before using the API


(Khairul Islam) #1

Hello, every one. I am working long time in the openmrs platform 1.8.0. recently I start 1.12.0 platform, but when I use rest controller I am facing this problem, how I resolve this issue. please help me If you can any one. thansk.


(Parth Kachchhi) #2

Seems like you are invoking REST from a thread other than main thread.

Please add the stack trace as it could be helpful in identifying the exact cause of the problem.


(Khairul Islam) #3

@themoonraker13 thanks, I don’t understand. Actually I want Integrate with angularjs, I need to send data in json format, so how I actually get it?


(Daniel Kayiwa) #4

@khairul is that a module some where like on github for us to look at and advise?


(Parth Kachchhi) #5

Like @dkayiwa said, please share the code that is getting you into all the trouble or point us to your module.


(Tomasz Mueller) #6

@khairul, @dkayiwa, @themoonraker13 Was this resolved? How? I am asking since it seems I’m facing something similar currently

Thanks, Tomasz


(Daniel Kayiwa) #7

@tmueller the person did not point us to the code which was causing this problem.