try {
$recordsArray = [
"data" => [
"First_Name" =>
"fname",
"Name" =>
"lname",
];
var_dump(
json_encode(
$recordsArray, JSON_PRETTY_PRINT));
$zcrmModuleIns =
ZCRMModule::
getInstance(
"contacts");
$bulkAPIResponse =
$zcrmModuleIns->
upsertRecords(
json_encode(
$recordsArray));
// $recordsArray - array of ZCRMRecord instances filled with required data for upsert.
$entityResponses =
$bulkAPIResponse->
getEntityResponses();
foreach (
$entityResponses as
$entityResponse) {
if (
"success" ==
$entityResponse->
getStatus()) {
echo
"Status:" .
$entityResponse->
getStatus();
echo
"Message:" .
$entityResponse->
getMessage();
echo
"Code:" .
$entityResponse->
getCode();
$upsertData =
$entityResponse->
getUpsertDetails();
echo
"UPSERT_ACTION:" .
$upsertData[“action”];
echo
"UPSERT_DUPLICATE_FIELD:" .
$upsertData[“duplicate_field”];
$createdRecordInstance =
$entityResponse->
getData();
echo
"EntityID:" .
$createdRecordInstance->
getEntityId();
echo
"moduleAPIName:" .
$createdRecordInstance->
getModuleAPIName();
}
}
}
catch (
ZCRMException
$e) {
//var_dump($e);
echo
$e->
getCode();
echo
$e->
getMessage();
echo
$e->
getExceptionCode();
}