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

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.

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.

@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?

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

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

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

Thanks, Tomasz

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

1 Like