"Codice eq '{$codice}'", 'CodiceRapporto' => "CodiceRapporto eq '{$codice}'", 'Numero' => "Numero eq '{$codice}'" ]; foreach ($filters as $label => $filter) { try { $data = $api->get('Rapporto', [ '$filter' => $filter, '$top' => 5, '$select' => 'IdRapporto,Codice,CodiceRapporto,Numero,Data,Versione,Cliente' ]); $attempts[$label] = [ 'success' => true, 'filter' => $filter, 'records' => isset($data['value']) && is_array($data['value']) ? count($data['value']) : null, 'data' => $data ]; } catch (Exception $e) { $attempts[$label] = [ 'success' => false, 'filter' => $filter, 'error' => $e->getMessage() ]; } } echo json_encode([ 'success' => true, 'input_codice' => $codice, 'attempts' => $attempts ], JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); } catch (Exception $e) { http_response_code(500); echo json_encode([ 'success' => false, 'error' => $e->getMessage() ], JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE); }