Trouble with Authentication and Privilege Errors Using OpenMRS API

Hi everyone,

I’m having with authentication and privilege errors when trying to use the OpenMRS API via cURL (and also in another application, when I try the request), although everything works fine in Postman. I’m using the default admin:Admin123 authentication encoded in Base64.

For instance, the following request works as expected in Postman. However, when I try it in cURL (with the -k flag to bypass a certificate error), I receive an error message about missing privileges:

curl -k -L -X GET 'http://localhost/openmrs/ws/rest/v1/encounter?patient=cdfc6d18-6f7c-4a94-b26c-baef4c804164' \
-H 'Authorization: Basic YWRtaW46QWRtaW4xMjM='

"error": {
  "message": "User is not logged in [Privileges required: Get Patients]",
  "code": "org.openmrs.aop.AuthorizationAdvice:111"
}

Any clues? Thanks in advance!

Using https instead of http fixed, it was redirecting to https and changing the cookie session it seems :sweat_smile:

1 Like