Creating custom Endpoints Suitecrm Rest API v8

Hello,

I have spent lots of time but did’t find good documentation to create custom endpoints in REST API V8.

I have check below documentation but its confusing .

https://docs.suitecrm.com/developer/api/version-8/customization/

Anyone please suggest good demo example for demo link

Thanks

@rigal did you able to create an custom api in SuiteCRM8. I’m facing the same issue because the documentation is very confusing

I found this one, it helped me, I hope for you the same.

This URL is not available anymore. Does anyone find some more documentation about this topic, because this (Customization :: SuiteCRM Documentation) is not working.

Where are you putting your customisations is it
custom/application/Ext/Api/V8 … Folder
Or
custom/Extension/application/Ext/Api/V8… Folder

Because the first one is the correct location

Thanks for your fast response.

My path (custom/application/Ext/Api/V8/Config/routes.php) is correct. I created the file routes.php and added the basic example code:

<?php
$app->get('/hello', function() {
    return 'Hello World!';
});

I did a ‘quick and repair’ and tried to go to the url: {suitecrm}/Api/hello, but still got the 404 (not found) error.

Your url will be {suitecrm}/Api/V8/custom/hello

1 Like

Thank you for your help, it works! Unfortunately this was not in the documentation.

Just one more question.

I want to get this endpoint without any authentication, so no need to have a access_token to GET/POST some data. Is it possible to disable the authentication for this specific endpoint, because I still get the error 401 (Unauthorized)?

Of the top of my head i don’t know how to disable authorization
But a simpler way (if you are not using any specific api functionality) to do what you want is to make an entrypoint (not an api endpoint) with authorization false

Thank you, but this is not what I want.

I have a external JavaScript front-end application (Vue.js) where customers can sign in and see there own projects and user details. So I am using the endpoints from SuiteCRM to show their data.

There is just one tiny problem. Because if they forgot their password, there must be the ability to reset their password with a “forgot password?” button. Sounds easy right? create a select-field with “user forgot password”. Then create a workflow in SuiteCRM that if the User-module changed, and the “user forgot password” is select, send an e-mail to the user and set the user_forgot_password back to false . But it is not possible to update a record while the user is not logged in, because they don’t have an access_token. So I wanted to create an endpoint "/Api/V8/custom/reset_password={user_name} and then trigger a method to update the record with the value: user_forgot_password = true.

Now you know my case, maybe there is a better solution. But I thought creating my own endpoint without authentication would be the best solution.

I also integrated a xamarin app with suitecrm through the api

For resetting password there is already a build in entrypoint “GeneratePassword” in the crn

Do you have an example. I also have Xamarin Experience, so that’s not a problem.

But you use the EntryPoint to “GeneratePassword” without an “access_token”. You can reach this EntryPoint without any authentication?

Actually that’s the same entrypoint (not an api endpoint) that crm ui uses to reset a users password. It obeys the password and reset settings set in password manager

        {
            var reply="";
            Uri uri = new Uri(string.Format(CRMUrls.baseCRMUrl, string.Empty));
            //var MyDynamic = new loginObject();
            //MyDynamic.grant_type = "password";
            //MyDynamic.client_id = CRMUrls.client_id;
            //MyDynamic.client_secret = CRMUrls.client_secret;
            //MyDynamic.username = username;
            //MyDynamic.password = password;

            //string json = JsonConvert.SerializeObject(MyDynamic);

            MultipartFormDataContent content = new MultipartFormDataContent();
            content.Add(new StringContent("GeneratePassword"), "entryPoint");
            content.Add(new StringContent(username), "user_name");
            content.Add(new StringContent(email), "user_email");
            content.Add(new StringContent("1"), "link");
            try
            {
                var response = await client.PostAsync(uri, content);

                if (response.IsSuccessStatusCode)
                {
                    string resp = await response.Content.ReadAsStringAsync();
                    reply = resp;
                    if (resp == "1")
                    {
                        return resp;
                    }
                }
            }
            catch (Exception e1)
            {
            }
            return reply;

        }  ```

Okay, I get it. You call the URL: {suitecrm}/index.php?entryPoint=GeneratePassword&user_name=xxx&user_email=xxx. Or am I wrong?

I think this is supposed to be a post call

Sorry, I was trying that, but I think I miss just something in my body.

The body is not raw it either form or x-www-urlen coded

Also tried form-data and x-www-form-urlencoded, but still the same response.

Add this link => 1 parameter as well