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!