狂饮6 https请求以错误500结尾

时间:2018-07-03 13:55:27

标签: php laravel-5 https guzzle6

我正在尝试在laravel的guzzle 6上发布请求...当我尝试在http协议下运行时,它正在运行,但是当我添加https ...时,它向我抛出“ 500内部服务器错误”。另外,当我尝试使用http协议时,它告诉我JSON格式不正确,但我不知道为什么! ...感谢您的时间。这是我的代码:

新客户

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

发布请求

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

0 个答案:

没有答案