Cannot get API to work

Hai Stephen,

Tnx for your reply. https://XXXXXX/tests/api/InternalApiTest.php
comes back with http-200 and an empty page… (empty head, empty body).

hi @vandijk, this works on one of the demos

curl --insecure -X POST -H 'Content-Type: application/json' 'https://six.openemr.io/b/openemr/apis/api/auth' \
-d '{
    "grant_type":"password",
    "username": "admin",
    "password": "pass",
    "scope":"default"
}'
1 Like

Hi Stephen,

Thanks for your reply and patients.
It looks like something is missing, installed Open-emr on another ubuntu server from scratch, no difference, nothing in error log.
Questions:

  1. should it work out of the box (without adding code or extensions ?)
  2. there is a recommendation during install how to configure the directive of the apache conf. (Denied access to /sites/ etc) should this be altered for using the api?
  3. is everybody in this thread, working with the docker build?

Regards,

Van dijk.

hi @stephenwaite ,
Nice call on using the demo (note the demo won’t even need the --insecure tag since it is using a genuine ssl cert) for testing. @vandijk , did Stephen’s above command work for you? (this will ensure that your curl client is working)
-brady

1 Like

Hi Brady,

Thank you for your response, in the screenshot above, I’m showing that curl is not working for the api. It also shows curl is working for the open-emr-site itself.

Kind regards,
Van Dijk

Ok, another build from scratch, this time the docker variant:
Open-emr works, enabled the rest-api setting, but still no luck:
… empty body …

double post…

Hi @stephenwaite

The curl-post on the demo-site works.

Kind regards

hi @vandijk, for the internal api test script, InternalApiTest.php, you have to edit it and remove the exit() function located at the top for security purposes.

Hi, i also got same issue.

Problem was .htacces was overridden by Apache default settings. So the rewrite in file /var/www/html/yoursite/apis/.htaccess do not work.
I solved the problem by adding this to the /etc/apache2/sites-available/yoursite.conf:
<Directory /var/www/html/yoursite>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all

This works for my test-site. Don’t use this blindly for a production site!!!

I don’t know why we are the only ones having this problem…

Yes but I managed with making custom API. I have made custom API with that admin can send dynamically message to any patient.

Thank you

@vandijk,

I am having same problem not able to do authenticate using rest api , can please share me your full flow what steps you had followed to resolve API issue. Below error is showing while doing authentication 404 Not Found or Bad Request

Thanks,
Nilesh

Hi All,

Here is final solution for API issue, when your API is not working or showing HTTP 404 error you means your .htaccess is not working just go to apache config file check AllowOverride option and change the AllowOverride None to AllowOverride All.

Now try again API url you should receive the internal server error means the our .htaccess is working but we did not enabled the apache mod_rewrite. use below command to enable mod_rewrite a2enmod rewrite then restart the server.

Note: If you install the separate apache server then and then only you will get this issue but you taken apache2 from OpenEMR site it will not going issue you because they already made that changes into the apache2 server.

Thanks,
Nilesh

1 Like

Hi @vandijk,

Is there any REST API document for v 5.0.2 that you referred to? I am trying to use opemEMR REST APIs too but not able to get hold of any API documentation. Any information on this would help.

Thanks,
Annapoorna

Here is the link for the API docs for version 5.0.2

Hi @Nilesh_Hake @brady.miller
I followed every step but still it is not working.


So i have installed openemr on a public ubuntu machine and the UI is working, I have a administrator set up just the authorization and apis is giving me a 404 error. I have changed openemr.conf in apache2/sites-available as per your comments to AllowOverride All but then too it doesn’t work

hi @Manan17 , are you using SSL(https)? It’s required based on the API README.

Hi @stephenwaite I did to it using ssl certificate. Now I am getting an error that my IP is refusing to connect after login

Hi @stephenwaite @brady.miller I have fixed this. I also have managed to get the SSL.
Now when I use https://182.xx.xx.xx/openemr it gives me the login page and I can get through it. Like shown here:

But when I try to register an API client through postman I get a 404 error.

Please help. This is urgent!!!
Also, I have tried keeping the URL in admin>global>connectors as https://localhost as well. Doesn’t work

1 Like