# 500 Internal Server error on Batch Update

**URL:** <https://community.hubspot.com/t/500-internal-server-error-on-batch-update/85720>\
**Category:** APIs & Integrations\
**Tags:** php, professional\
**Created:** [July 20, 2023, 2:50am UTC](https://community.hubspot.com/t/500-internal-server-error-on-batch-update/85720 "2023-07-20T02:50:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![miguelomonroyb](https://avatars.discourse-cdn.com/v4/letter/m/85f322/32.png) [@miguelomonroyb](https://community.hubspot.com/u/miguelomonroyb)\
**Post date:** [July 20, 2023, 2:50am UTC](https://community.hubspot.com/t/500-internal-server-error-on-batch-update/85720/1 "2023-07-20T02:50:29Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [July 20, 2023, 7:29pm UTC](https://community.hubspot.com/t/500-internal-server-error-on-batch-update/85720/2 "2023-07-20T19:29:18Z")

</div>

Hey, @miguelomonroyb 👋 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

---

<div class="post-metadata">

**Author:** ![miguelomonroyb](https://avatars.discourse-cdn.com/v4/letter/m/85f322/32.png) [@miguelomonroyb](https://community.hubspot.com/u/miguelomonroyb)\
**Post date:** [July 21, 2023, 1:32pm UTC](https://community.hubspot.com/t/500-internal-server-error-on-batch-update/85720/3 "2023-07-21T13:32:35Z")

</div>

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);

}
