Search code examples
phpweb-servicesapirestconsuming

rest api (client side) is working fine on local server but not on online server


The following code works fine on local server but on online server throws HTTP ERROR 500. cURL is also enable. Have checked the error log it say;

AH01071: Got error 'PHP message: PHP Fatal error: Uncaught exception 'Pph\ApiClientException' with message 'Unknown error HTTP/1.1 400 BAD REQUEST\r\nSe

$tcom = $ApiClient->apiCall('get', 'companies');
echo "<table>"; 
foreach($tcom as $key=>$value){

  foreach($value as $k => $v){
    echo'<tr>';
    echo '<td>'  . $k . '</td>';
    echo '<td>'  . $v . '</td>';
    echo '</tr>';
  }
}
echo "</table>";

Solution

  • Have to provide one (human, phpserialize, json) as URL parameter like this: &format=phpserialize\n)\n'

    Example: $tcom = $ApiClient->apiCall('get', 'companies&format=phpserialize');