Seems that parameters not defined in the system UserOptions datashape can not be set as an expected input parameter of Create User services (see article CS245936).
But you can use the below workaround instead:
var params = {
infoTableName : "InfoTable",
dataShapeName : "UserOptions"
};
// CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE(UserOptions)
var result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);
var row = new Object ();
row.userName="testUser2";
var password = Resources["EncryptionServices"].EncryptPropertyValue({data: "Login@thingworx"});
row.password = password; //password
result.AddRow(row);
Resources["EntityServices"].CreateUserWithOptions({
userOptions: result /* INFOTABLE */
});
Users["testUser2"].emailAddress="abc123@gmail.com";
That is after the creation of a user, we can set its user extension parameters directly in code.