Need some help getting started with the API

First thanks to everyone involved in this fantastic CRM. I’m coming from 17hats to SuiteCRM, and very happy so far. One of the things that I’m really excited about is the ability to utilize the API. Ultimately I’d like to push new wordpress users into SuiteCRM as leads.

I’ve got some limited experience with APIs, and I think I may have some pretty basic questions, but here goes:

I’ve created my “Client Credentials Client” inside of SuiteCRM, but when I try and request a token in postman I get 500 errors, and can’t get things to work.

Grant Type - Client Credentials
Access Token URL = https:// my install /Api/access_token
Client ID - client id from Suite CRM
Client Secret - the secret I set in SuiteCRM
Scope - I’m leaving this blank.

When I hit “request token” in postman, it just tells me that it failed to completed Oauth 2.0 login with a 500 error code.

SuiteCRM Version 7.11.10
Sugar Version 6.5.25 (Build 344)

Any thoughts on where I should go from here?

Welcome to SuitCRM community!

Double check php error log in the server where SuiteCRM is hosted. Additionally double check suitecrm.log in the root of SuiteCRM instance.

Regards

1 Like

You rock!

the error_log showed that I had a problem with my private key:

[10-Feb-2020 04:17:10 UTC] PHP Fatal error:  Uncaught LogicException: Key path "file:///home/XXX/public_html/Api/V8/OAuth2/private.key" does not exist or is not readable in /home/XXX/public_html/vendor/league/oauth2-server/src/CryptKey.php:45

It was not owned by the webserver user. So after I chmod’ed it, I’m up and running.

Now I just need to learn how to create a sales lead with the API.

Thanks again.

1 Like

For future people reading this.

Assuming you have generated your public.key and private.key files with OpenSSL, did you set permissions properly on your public.key and private.key files that you generated in your /Api/V8/OAuth2 folder so that apache can access them?

You can set permissions with these 2 commands:

sudo chmod 600 private.key public.key
sudo chown www-data:www-data p*.key

If you haven’t generated public.key and private.key navigate to your /Api/V8/OAuth2 folder and do the following commands:

openssl genrsa -out private.key 2048
openssl rsa -in private.key -pubout -out public.key

Then set the file permissions.

sudo chmod 600 private.key public.key
sudo chown www-data:www-data p*.key

This is documented here: https://docs.suitecrm.com/developer/api/developer-setup-guide/json-api/#_before_you_start_calling_endpoints

3 Likes

You are exactly right JosephN. The instructions were correct, I just skipped a step. When I created the files they were owned by root.