'Transform CURL in Http facade

I have a big problem to transform CURL to Http facade in Laravel. So I have the code :

$httpParams = [
    'textData'  =>  $xml->asXML(),
    'xmlFile'   =>  new \CurlFile($params['file']->getPathName())
];
$curlHandle = curl_init('http://url.com');
curl_setopt($curlHandle, CURLOPT_HEADER, false);
curl_setopt($curlHandle, CURLOPT_POST, true);
curl_setopt($curlHandle, CURLOPT_POSTFIELDS, $httpParams);
curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true);
$curlResponse = curl_exec($curlHandle);
curl_close($curlHandle);
dump($curlResponse); die();

I have the XML response and status is 200.

Next I using Postman (is working just fine), I have response data the XML:

enter image description here

When I try to do with Laravel, I have the status 200 but the response is "". I tried multiple ways but still didn't work:

  $http = Http::withHeaders([
    'Content-Type' => 'multipart/form-data;',
  ])->withOptions([
    'debug' => true,
  ]);
  $httpParams = [
    'textData'  =>  $xml->asXML(),
    'xmlFile'   =>  new \CurlFile($params['file']->getPathName())
  ];
  dump($http->send('post', $endpoint, $httpParams)->body());die();

How can I modify this code in order to works fine with Http facade also?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source