mardi 3 juillet 2018

Guzzle 6 https request ends with error 500

I'm trying to make a post request on guzzle 6 on laravel...when I try to do it under http protocol it's working but when I add https...it throws me a "500 internal server error" ...Thank you for your time.This is my code:

New Client

$this->cliente  = new Client([
       // Base URI is used with relative requests
       'base_uri' => 'https://validar.r9.cl',
       // You can set any number of default request options.
       'timeout'  => 2.0
    ]);

Post Request

public function sendValidation($data){

  $json = json_encode($data);

  try {
    $response =  $this->cliente->request('POST', 'validate',[
                'json' => $json,
                'headers' =>  [ 'Accept' => 'application/json',
                                'Content-type' => 'application/json'],
                'verify' => false,
                ]);

  } catch (RequestException $e) {
      echo Psr7\str($e->getRequest());
      if ($e->hasResponse()) {
          echo Psr7\str($e->getResponse());
      }
  }


  #dd($response->getBody()->getContents());

  #return json_decode($response->getBody()->getContents());
}

Data

$data = array(
                'xls_path' => 'C://Users\IngenieroR9\dev_projects\validar_estacion\testing\dataset\Planilla_Import_SMA_-_MP_-_3_PAR_-_DV4.xlsx',
                'estacion' => 'Bodega',
                'params' => array("MP10", "MP2,5", "SO2")
                );



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire