Page 1 of 1

API issue in create individuals customer

Posted: Wed Feb 09, 2022 5:26 am
by SyncEzy
I'm creating individual customer with following api
/api/v1.0/companies/{companyID}/customers/individuals/

but it is giving me following response:
"response" => "{"errors":[{"path":null,"message":"No data to be inserted for individual customer.","value":null}]}"

My params are following:
array:12 [
"Title" => ""
"CustomerType" => "Customer"
"GivenName" => "Test"
"FamilyName" => "Contact hs 102"
"Email" => "[email protected]"
"WorkPhone" => ""
"Fax" => ""
"CellPhone" => ""
"AltPhone" => ""
"Department" => ""
"Position" => ""
"Notes" => ""
]

Re: API issue in create individuals customer

Posted: Wed Feb 09, 2022 5:40 am
by robbertcha
Hi,

The format of creating an individual customer should be Object, not array, however please add ',' at the end of each column:-

Code: Select all

{
    "Title" :"",
    "CustomerType" : "Customer",
    "GivenName" :"Test",
    ...
}

Re: API issue in create individuals customer

Posted: Wed Feb 09, 2022 6:17 am
by SyncEzy
Yes its object and there is no error in syntax, this is how it is exactly looking:

$customerInfo = new stdClass();
$customerInfo->Title = '';
$customerInfo->CustomerType = 'Customer';
$customerInfo->GivenName = $firstName;
$customerInfo->FamilyName = $lastName;
$customerInfo->Email = $email;
$customerInfo->WorkPhone = $workPhone;
$customerInfo->Fax = $fax;
$customerInfo->CellPhone = $mobilePhone;
$customerInfo->AltPhone = $altPhone;
$customerInfo->Department = $department;
$customerInfo->Position = $position;
$customerInfo->Notes = $notes;

Re: API issue in create individuals customer

Posted: Wed Feb 09, 2022 10:15 pm
by robbertcha
Hi,

Yes, the example I provide before is the JSON Object format, I think you might need to use json_encode() to convert php object to json format before posting/patching via simPRO API.

Re: API issue in create individuals customer

Posted: Thu Feb 10, 2022 6:21 am
by SyncEzy
Okay got it, thank you