SuiteCRM 8.1 Successful Api Calls

Hi Everyone,
I’ve had a hard time using the api when instructed to do so. Something that should be pretty straightforward and easy going.

Our situation: We have a SuiteCrm 8.1.2 running on an azure vm.
So I’ve read through the documentation and figured I had a pretty good understanding of connecting to the v8 api. But even getting an access token was a pita.

So after numerous trial and error calls, I figured it out and wanted to share it here. So maybe the next person will find it quicker.

I assume you have a 8.1.2 version up and running. I can’t speak for earlier or later versions.
At first go on to the server on which it is running and create the oauth keys, as per instruction.

By now, you will see that the path in the documentation is not there, but it’s inside of the ‘legacy’ folder. This is pretty integral to what went wrong for me. I figured that there must be some kind of redirection of the routes for the api (there’s not).

Go onto your SuiteCRM dashboard and go into the settings and create a new api user.
Btw, for me, it didn’t show me a created password in the front-end. So I typed one in myself.

I had downloaded the swagger and postman collections, because I thought I must be doing something wrong with my paths.
First of all, the api paths are Case sensitive!!, don’t know who thought that this was a good idea… Anyway.
As we remember, there is this ‘legacy’ folder. As it turns out, this is also needed for the api calls.

So to get an api token, we need to call the /access_token endpoint with the information we received when we created the api user as the json body:

    {
        "grant_type": "client_credentials",
        "client_id": "b5bd3e8a-d547-b31c-0beb-62f64f7xxxxx",
        "client_secret": "apipw123123123"
    }

LINK HERE: Same documentation page as the one where you generate the oath keys but lower on the page, under the header “Authentication”. (cannot post more than two links.

But the url is not (as documented):

{{suitecrm.url}}/Api/access_token

But the correct url is:

{{suitecrm.url}}/legacy/Api/access_token

For the record, this is a POST call and my suitecrm.url is just our instance with nothing behind it.

[POST] https://crm.domain.nl/legacy/Api/access_token

Now you’ll receive a token that’s valid for an hour, which you can use to make your (get/post/etc) calls to the api (e.g.):

[GET] {{suitecrm.url}}/legacy/Api/V8/module/Accounts

Notice the absence of the V8 while calling the access_point endpoint and the addition of it for the modules

I hope this saves someone some time. I did not find this information anywhere in the documentation. Maybe I have missed it, or didn’t look in the right places. But this is the version I’ve jumped into, I don’t have prior knowledge or followed the changelogs etc. So I figured that someone might have the same problem and this will help.

The documentation for suitecrm 8+ is pretty small, So I thought that everything else was the same.
I can update the documentation, if needed. But as this is all my experience with SuiteCrm so far, I don’t know if this would be helpful, as it is sparse at best.

Happy coding!

2 Likes

Hey there!

Thanks for noting this distinction between Suite7/Suite8.

This is a good point to make
Some of the routing / paths that SuiteCRM 8 uses will be different from how Suite7 behaves

So, the necessity of including /legacy/ (which points to the Suite7 backend), isn’t immediately clear.


This, along with any other SuiteCRM8 documentation issues, would be worth raising on the SuiteDocs github repo: Issues · salesagility/SuiteDocs · GitHub

Would you be able to raise this issue here, if you get a chance?

Thanks!

Hi @yhorndt and @John ,
I’m running a SuiteCrm 8.2.1 installed via Softaculous on linux Plesk server and to me the path of API is {{suitecrm.url}}/public/legacy/api/ whith “A” in lowercase and it redirect to /public/legacy/lib/API/public/index.php.

I don’t know if I did something wrong while installing and activating the API so that my path is slightly different from yours.

Strangely though the API path is api (lowercase) the path to the postman collection is

{{suitecrm.url}}/public/legacy/Api/docs/postman/SalesAgility.postman_collection.json

with “Api” instead “api”.

Anyway I haven’t tested the API yet but the paths seem to work normally. I brought this question to the forum to document that this small difference can occur.