function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ahsensahsens 

Creating Users via API

Is it possible to create a SFDC user, create roles and set its rights via AppExcahnge API ?
 
Best Regards
Ahsen Saeed ( ahsensaeed@hotmail.com)
 
 
 
SuperfellSuperfell
You can create users and update profiles via the API (and i'm pretty sure you can create roles as well). You can not create new profiles via the API.
ahsensaeedahsensaeed
can we set the field level security for each role via API or at least can we view it ?
 
benjasikbenjasik
Field Level Security is implicity applied for each user through the API.

We do not have a way to set it through the API yet, but it's on our API roadmap
azadazad
Is it possible to create a user via the API (using PHP), using a "developer account"?
I'm getting the error "Unable to create/update fields: Name. Please check the security settings of this field and verify that it is read/write for your profile."

Please find the details here:
My Salesforce developer id: mohammad.azad@hitechito.com

--------------------------------------------------------------------------------
PHP Code to create the user via API:

$sObject = new SObject();
$sObject->type = 'User';
$sObject->fields = array(
'Username' => 'mohammad@ktgraphics.com',
'LastName' => 'Last',
'FirstName' => 'First',
'Name' => 'First Last',
'Email' => 'mohammad@ktgraphics.com',
'Alias' => 'mohammad@ktgraphics.com',
'CommunityNickname' => 'mohammad@ktgraphics.com',
'IsActive' => 'true',
'TimeZoneSidKey'=> 'America/New_York',
'LocaleSidKey' => 'en_US',
'EmailEncodingKey' => 'ISO-8859-1',
'ProfileId' => '00e80000000pdX4AAI',

'LanguageLocaleKey' => 'en_US',
);

$rsp = $client->create(array($sObject));
--------------------------------------------------------------------------------

Here goes the response:

stdClass Object
(
[errors] => stdClass Object
(
[fields] => Name
[message] => Unable to create/update fields: Name. Please check the security settings of this field and verify that it is read/write for your profile.
[statusCode] => INVALID_FIELD_FOR_INSERT_UPDATE
)

[id] =>
[success] =>
)
--------------------------------------------------------------------------------
SuperfellSuperfell
You already set firstname and lastName, no need to set name as well.