Hey Genadij,
Thank you, After running that it worked. I created the package, then added the organization...
Only problem now is that if I browse to the exchange mail page and click on add new account. I am met with this error in the UI. This error only pops up on this account though? Why would that be?
System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.NullReferenceException: Object reference not set to an instance of an object.
at SolidCP.EnterpriseServer.ExchangeServerController.GetMailboxSetupInstructions(Int32 itemId, Int32 accountId, Boolean pmm, Boolean emailMode, Boolean signup, String passwordResetUrl)
at SolidCP.EnterpriseServer.esExchangeServer.GetMailboxSetupInstructions(Int32 itemId, Int32 accountId, Boolean pmm, Boolean emailMode, Boolean signup, String passwordResetUrl)
Probably you missed some steps when used SOAP and now it can't get some object.
Try to create it without SOAP and check what did you miss.
That's the thing. I am taking every step... I'm not sure what I missed. In fact with SOAP there are a few things that have more steps, like creating the organization manually where with the UI it's done automatically...
I have no idea what I could be missing...
Is there a way to create the org directly with the AddPackageWithResources call?
Or is there a way to try and determine what is being missed? Maybe some log?
There isn't way to create everything with one method. SolidCP uses 2-5 SOAP methods to create one thing.
For creating organization you should use the method CreateOrganization()
So I had a look to try and determine if I am making a mistake and it looks like I am submtting it correctly from what I can see atleast...
Maybe you can advise. I keep running into the same error, even on different user's the API creates so I must be missing something???
I have added a summarized version of the function below with the steps we take. Please advise if we're missing a step maybe?
Summarized Code:
The domain & email:
$email = $params['customfields']['Email Address'];
$email_parts = explode('@', $email);
Check if user exists:
$user_check = $api->APIExecute('esUsers.asmx', 'UserExists', ['username'=>$username]);
If user does not exist, Create it:
$SolidCPUser = $api->APIExecute('esUsers.asmx', 'AddUserLiteral', [
'ownerId' => 1,
'roleId' => 3,
'statusId' => 1,
'isPeer' => false,
'isDemo' => false,
'username' => $username,
'password' => substr(md5($username),0,10),
'firstName' => $params['clientsdetails']['firstname'],
'lastName' => $params['clientsdetails']['lastname'],
'email' => $params['clientsdetails']['email'],
'companyName' => $params['clientsdetails']['companyname'],
'ecommerceEnabled' => false,
'sendLetter' => false,
'htmlMail' => false,
]);
Grab the user (Either existing or just created)
$SolidCPUser = $api->APIExecute('esUsers.asmx', 'GetUserByUsername', ['username' => $username])->GetUserByUsernameResult;
Grab the hosting plan we linked to the product
$SolidCPPackage = $api->APIExecute('esPackages.asmx', 'GetHostingPlan', ['planId' => $ourProduct->PlanID])->GetHostingPlanResult;
Create Hosting Plan For User
$planVars = [
'userId' => $SolidCPUser->UserId,
'planId' => $SolidCPPackage->PlanId,
'spaceName' => $SolidCPPackage->PlanName,
'statusId' => 1,
'sendLetter' => false,
'createResources' => true,
'domainName' => $email_parts[1],
'tempDomain' => $email_parts[1],
'createWebSite' => false,
'createFtpAccount' => false,
'ftpAccountName' => '',
'createMailAccount' => false,
'hostName' => '',
];
$SolidCPUserPackage = $api->APIExecute('esPackages.asmx', 'AddPackageWithResources', $planVars)->AddPackageWithResourcesResult;
Create Organization
$SolidCPUserPackageOrg = $api->APIExecute('esOrganizations.asmx', 'CreateOrganization', [
'packageId' => $tblcustomfieldsvalues->value, /* This value is the ID value received from creating the package on the user */
'organizationID' => $email_parts[1],
'organizationName' => $email_parts[1],
'domainName' => $email_parts[1]
])->CreateOrganizationResult;