How to get firstname and lastname from login rest api

How can i get First name and Last name from login rest api?

Hi,
are you using a specific version (4 / 8)?

The v4 does not return first/last name while logging in. But you can do a second request, e.g. get_entry for that purpose.

E: example:

{
	"session": "{{sessionid}}",
	"module_name": "Employees",
	"id":"your-user-id",
    "select_fields ": ["first_name", "last_name"],
    "link_name_to_fields_array": []
}

it will return something like:

{
    "entry_list": [
        {
            "id": "your-user-id",
            "module_name": "Employees",
            "name_value_list": {
                "first_name": {
                    "name": "first_name",
                    "value": "Test"
                },
                "last_name": {
                    "name": "last_name",
                    "value": "Tester"
                }
            }
        }
    ],
    "relationship_list": []
}
1 Like

Hello @crmspace,

Thank You For You Response. But I don’t want to do second request .
I have find solution myself you can also use this if you have require.

I have added this below new line of code in SugarWebServiceImplv4.php

$nameValueArray[‘first_name’] = self::$helperObject->get_name_value(‘first_name’, $current_user->first_name);
$nameValueArray[‘last_name’] = self::$helperObject->get_name_value(‘last_name’, $current_user->last_name);

Hi,
that’s an option too, and congrats for the workaround.
Just one additional comment: I’m afraid that your solution is not upgrade-safe, you could lose this modification during the next update. As an alternative option, you could create your own api methods:

(but I’ve never seen a custom login method - could be interesting)

1 Like

Hi @crmspace,

Okay Great, I’ll try for custom login method whenever i free. I’ll give you custom login method after some days.

1 Like

Hi @ankitlakhara,
thanks for sharing your code with the community, we highly appreciate that!

1 Like