Bahmni Connect: Error 400 (Bad Request) on `event-log-service/rest/eventlog/events/encounter`

Hi !

Starting from a fresh installation of Bahmni 0.89 (no Odoo), I have followed the different wiki steps to install Bahmni Connect. Installing+Bahmni+Connect+on+Server Bahmni+Connect+Deployment+Steps

Plus I have added to the SSL certs (OpenMRS Talk: Bahmni Connect (0.89): ERR_INSECURE_RESPONSE).

The Bahmni Connect initial sync is starting (I am asked to log in) but then quickly returns an error:

Could not connect to the server. Please check your connection and try again

Initial sync failed. Please contact system administrator.

In the Chrome console:

GET 400 (Bad Request)

Any idea what could cause this?

Event log service is correctly running:

$ sudo service bahmni-event-log-service status
Service bahmni-event-log-service is running with pid: 5204



Hi @mksrom,

It would be worth checking openMRS login credentials in the file at the below location.


In the OpenMRS, Administration – Advanced Settings, you will have to configure the sync strategy to be either ID based or address based.

ID Based bahmniOfflineSync.strategy = org.bahmni.module.bahmniOfflineSync.strategy.IDBasedSyncStrategy

Location Based. bahmniOfflineSync.strategy = org.bahmni.module.bahmniOfflineSync.strategy.LocationBasedSyncStrategy

Additionally, if its Location based, then the login location should in OpenMRS should be assigned address hierarchy.

Please check the logs in /var/log/bahmni-event-log-service and gather more information on the cause of issue. Also please refer to the link below as there have been improvements in initial sync for Connect.

Sorry for the late response. I am still experiencing this problem.

$ cat /opt/bahmni-event-log-service/bahmni-event-log-service/WEB-INF/classes/


# Keep the connection alive if idle for a long time
spring.datasource.validationQuery=SELECT 1






Is there anything abnormal in this? I have tried to change the credentials to:


But this didn’t change anything. Still the same error…

This is configured with the ID based strategy:

Here is the Bahmni Event Log Service log:

Now looking at the error message returned:

‘filterBy’ is not present… ?

Does anyone have successfully installed Bahmni Connect (from version 0.89)?

@darius, @gsluthra, are you aware of any implementation that uses Bahmni Connect installed on server, preferably on version 0.89?

In short:

filterBy is empty because EventLogFilterController is returning empty arrays.

Call made:

Response returned: {"patient":[],"offline-concepts":[],"addressHierarchy":[],"encounter":[]}

In the demo server, the call made is the following (note that the addressUuid is different for some reason):


(Q) Why is it returned empty in my freshly installed server, but it returns ‘GAN’ in the demo server? Is there some metadata that I need to manually add or something?

Debugging details (optional to read):

  • The filterBy parameter is indeed required by the EventLog resource (here):
...@RequestParam(value = "filterBy", required = true) String[] filterBy) {

###In BahmniApps (front-end):

  • filterBy is set to marker.filters (here).But it is an empty array.
  • skipping few steps
  • Markers are fetched by offlineMarkerDbService#getMarkers
  • But the marker for category “encouner” contains an empty array for filters

marker.filters is empty

  • Empty filters seems to be normal for the first time sync. So there is
marker.filters = offlineService.getItem("initSyncFilter");

(here) that is run at the fisrt syncing.

  • the item “initSyncFilter” is set as the “categoryFilterMap” object contents
offlineService.setItem("initSyncFilter", categoryFilterMap[category]);
  • And finally, categoryFilterMap is fetched from the server here:
var getFilterForCategoryAndLoginLocation = function (providerUuid, addressUuid, loginlocationUuid) {
    var url = Bahmni.Common.Constants.eventlogFilterUrl + "/markers/" + providerUuid + "/" + addressUuid + "/" + loginlocationUuid;
    return $http.get(url, {method: "GET", withCredentials: true});

This call returns empty filters for the encounters:

URL called: Result returned: {"patient":[],"offline-concepts":[],"addressHierarchy":[],"encounter":[]}

###In Bahmni Offline Sync (back-end)

The call is handled by the Bahmni Offline Sync module (here) which then calls the So here is where the filters are set empty:

        Location location = locationService.getLocationByUuid(loginLocationUuid);
        Map<String, List<String>> categoryFilterMap = new HashMap();
        final Collection<LocationAttribute> activeAttributes = location.getActiveAttributes();
        ArrayList<String> filters = new ArrayList<String>();

        for (LocationAttribute attr : activeAttributes) {
            if (attr.getAttributeType().getName().equals("IdentifierSourceName")) {
                String prefix = getPrefixFor(attr.getValue().toString());
                if (prefix == null) {
                    RuntimeException exception = new RuntimeException("Please check [IdentifierSourceName] config for [" + location.getName() + "]");
                    throw exception;

        categoryFilterMap.put("patient", filters);
        categoryFilterMap.put("encounter", filters);
        categoryFilterMap.put("addressHierarchy", new ArrayList<String>());
        categoryFilterMap.put("offline-concepts", new ArrayList<String>());

        return categoryFilterMap;

Hi mksrom,

By looking at your freshly installed server, the global property ‘bahmniOfflineSync.strategy’ is different from the demo server.

and if you are using IDBasedStrategy, you need to set the IdentifierSourceName as one of the Prefixes of Patient Identifier like GAN.

1 Like

That is just because I have tried different Offline Sync strategies. At the time I’ve written this post and all troubleshooting steps, the strategy was set to IDBasedSyncStrategy.

However, I haven’t seen that I was missing the IdentifierSourceName to be mapped with the prefix. Thanks a lot for looking into this.

That will probably solve my problem. I try and let you know.

It works. Thanks a lot. :thumbsup: Though very quickly I encounter another error in the clinical screen which will be the subject of another thread.

1 Like