500 Internal Server error on Batch Update

Hi there, We are using the API to update some deals using batch:
POST/crm/v3/objects/deals/batch/update

So, in our website the code builts many SimplePublicObjectBatchInput as required and a single

BatchInputSimplePublicObjectBatchInput and when the API is called it returns following error:

Exception when calling basic_api->update: [500] Server error: ‘POST https://api.hubapi.com/crm/v3/objects/deals/batch/update’ resulted in a ‘500 Internal Server Error’ response:
{“status”:“error”,“message”:“internal error”,“correlationId”:“dd8cc1fa-da7e-4f99-b10a-5d8fd859901d”}

We try our code with 2 records and It works fine, now the real test is trying to update 55 records at once, and It’s not working

Hey, @miguelomonroyb :waving_hand: Welcome to the community!

Can you share an example request, please? Seeing the full example can help the community understand what the formatting issue might be. Or it can allow us to try to reproduce your issue using a same/similar example.

Thank you! — Jaycee

Hi Jaycee, thank yoo for your response, here It is

The program querys a database, the query returns the field ‘CARTERA’ and this field indicates the deal_stage that mus bew updated on the pipeline:

$client = Factory::createWithAccessToken(TOKEN_HUBSPOT);

$i = 0;

while ($arr_Cartera = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {

if ($arr_Cartera[‘CARTERA’] != NULL) {

$paramsRO = array(

‘where’ => ‘t.post_title = "’ . $arr_Cartera[‘CEDULA’] . ‘" and t.post_status = “private”’

);

$obj_registro_obligacion = pods(‘registro_obligacion’, $paramsRO);

// Here the program gets and invoice number

if (!empty($obj_registro_obligacion->display(‘ref_cuota_inicial’))) {

$sql = " select reb.impcob VALOR_PAGO

from talu_rebut reb

where

reb.refreb = ‘" . $obj_registro_obligacion->display(‘ref_cuota_inicial’) . "’";

$result = consultar_bd_uxxi($sql);

// Here the program querys antoher database to check if the invoice is already paid

while (oci_fetch($result)) {

$valor_pago = oci_result($result, ‘VALOR_PAGO’);

if(!empty($valor_pago) && $valor_pago > 0){

$params = array(

‘where’ => “documento_identidad.meta_value = '” . $arr_Cartera[‘CEDULA’] . “’ and t.post_status = ‘private’”

);

$obj_Admitido = pods(“admitido”, $params);

$id_DealHubspot = $obj_Admitido->display(“deal_id_hubspot”);

// Here the program obtains the deal_id for that user

if (isset($id_DealHubspot)) {

$properties = [

“dealstage” => $arr_Cartera[‘CARTERA’],

“pipeline” => 9821569 // Gestión de cartera

];

// Here the program begins the construccion of the batch

$x = ‘simplePublicObjectBatchInput’.$i;

$$x = new SimplePublicObjectBatchInput([

‘properties’ => $properties,

‘id’ => $id_DealHubspot

]);

$i++;

}

}

}

}

}

else {

// If ‘CARTERA’ is NULL the program breaks the loop

break;

}

}

// Here the program creates an array of BatchInput Objects

for($j=0; $j<=$i; $j++){

$arr_Updates[$j] = ${‘simplePublicObjectBatchInput’.$j};

}

$obj_LoteUpdate = new BatchInputSimplePublicObjectBatchInput([

‘inputs’ => [],

]);

$obj_LoteUpdate->setInputs($arr_Updates);

try {

$apiResponse = $client->crm()->deals()->batchApi()->update($obj_LoteUpdate);

var_dump($apiResponse);

} catch (ApiException $e) {

// Here occurs the 500 internal server error exception

guardar_log(‘Gestión de cartera’, 'Fallo al reportar la cartera en Hubspot: Exception when calling basic_api->update: ’ . $e->getMessage(), basename($_SERVER[‘PHP_SELF’]), false);

}