Calling REST/FHIR API from OpenEMR AWS Install

Situation
Have installed OpenEMR on AWS and trying to call REST Api… both from Postman and browser and I am getting 500 Internal server error…
I havent changed any settings…the install is totally out of the box setup…

http://XXXXX.compute-1.amazonaws.com/apis/default/api/facility

I cam calling it as the above url and getting 500 error

You’ll need to provide more details than what you have provided. We need to know the OpenEMR version you installed (any relevant patches) whether this was done via docker, kubernetes, the Amazon AMIs.

It would also be helpful if you posted your API request and the relevant server error logs. W/o additional information there’s really not much anyone can help you with.

Hi Stephen…Thanks for the response…
I installed Amazon AMI into the AWS Instance and I am not able to access the API…

BTW I tried to install OpenEMR on XAMPP windows and I am facing the same issues…I am not getting any response for API calls and when I run http://localhost/openemr/tests/api/InternalApiTest.php it is loading an empty page…

I have already modified .htaccess file to AllowOverride All and activated rewrite…

I have also enabled the settings in administration/connector…

Not sure what is is wrong…

Do you know how to get the server logs? What do your logs show? If you run on your AWS machine

tail -f /var/log/apache2/error.log

It should tell you why you are getting the 500 error.
Also, you still are not posting the HTTP Request/Response (Postman gives you this information). I imagine something in your request is triggering the error.

I am getting the below error in my local:

127.0.0.1 - - [30/Oct/2021:01:32:21 +0530] “GET /openemr:80300/tests/api/InternalApiTest.php HTTP/1.1” 403 299 “-” “Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:93.0) Gecko/20100101 Firefox/93.0”
127.0.0.1 - - [30/Oct/2021:01:32:45 +0530] “GET /openemr/tests/api/InternalApiTest.php HTTP/1.1” 200 - “-” “Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:93.0) Gecko/20100101 Firefox/93.0”
127.0.0.1 - - [30/Oct/2021:01:32:45 +0530] “GET /favicon.ico HTTP/1.1” 200 30894 “http://localhost/openemr/tests/api/InternalApiTest.php” “Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:93.0) Gecko/20100101 Firefox/93.0”

[Sat Oct 30 01:32:21.747747 2021] [core:error] [pid 15920:tid 608] (20024)The given path is misformatted or contained invalid characters: [client 127.0.0.1:64639] AH00127: Cannot map GET /openemr:80300/tests/api/InternalApiTest.php HTTP/1.1 to file
[

when I access api directly from browser (http://localhost/openemr/apis/default/api/facility) then I get the below error:

[Sat Oct 30 01:36:43.568494 2021] [php7:error] [pid 15920:tid 608] [client 127.0.0.1:64713] PHP Fatal error: Uncaught LogicException: Key path “file://D:/xampp/htdocs/openemr/sites/default/documents/certificates/oapublic.key” does not exist or is not readable in D:\xampp\htdocs\openemr\vendor\league\oauth2-server\src\CryptKey.php:52\nStack trace:\n#0 D:\xampp\htdocs\openemr\vendor\league\oauth2-server\src\ResourceServer.php(50): League\OAuth2\Server\CryptKey->__construct(‘file://D:/xampp…’)\n#1 D:\xampp\htdocs\openemr\_rest_config.php(203): League\OAuth2\Server\ResourceServer->__construct(Object(OpenEMR\Common\Auth\OpenIDConnect\Repositories\AccessTokenRepository), ‘D:/xampp/htdocs…’)\n#2 D:\xampp\htdocs\openemr\apis\dispatch.php(56): RestConfig::verifyAccessToken()\n#3 {main}\n thrown in D:\xampp\htdocs\openemr\vendor\league\oauth2-server\src\CryptKey.php on line 52

[

Check permissions and also ensure the certificates keys are getting created…

Are you running this on your local machine or on amazon AWS? I’m pretty sure we don’t have a windows OpenEMR AMI.

Also port 80300 is not a standard port as the default is 8300. Did you install OpenEMR onto a windows machine in the amazon cloud? If so as Jerry said it looks like a file permission issue as your keys can’t write to the directory.

1 Like

Permissions are all good but certificate keys are not getting generated under certificates folder…

All the logs are from my local Windows XAMPP installation.

I have installed AMI as well but I want to make my local work first then look into AMI

The permissions can’t be right as the error literally says that the PHP process does not have access to the file://D:/xampp/htdocs/openemr/sites/default/documents/certificates folder.

1 Like

Windows gets weird with external drives or drives other than c:. Check security settings.
FYI: the keys get saved to file system here src/Common/Auth/OAuth2KeyConfig.php around L-137 to troubleshoot…