Пытаю отправить в систему файл, есть хелп, в котором написано :
Через guzzle пытаюсь отправить:
//Отправить файл в задачу
$url = get_file_path('f14341','64','Брандт А.Г..pdf');
$headers = [
'Content-Type' => 'multipart/form-data',
'Authorization' => 'Bearer токен',
];
$client2 = new GuzzleHttp\Client([
'headers' => $headers
]);
$res = $client2->request('POST', 'https://api.pyrus.com/v4/files/upload', [
'multipart' => [
[
'name' => 'Брандт А.Г..pdf',
'contents' => fopen($url, 'r')
],
]
]);
echo '<pre>'.$res->getStatusCode().'</pre>';
echo '<pre>'.$res->getHeader('content-type').'</pre>';
echo '<pre>'.$res->getBody().'</pre>';
Но возвращает ошибку:
Fatal error: Uncaught GuzzleHttp\Exception\ClientException: Client error: `POST
https://api.pyrus.com/v4/files/upload` resulted in a `400 Bad Request` response in /var/www/html/cb/vendor/guzzlehttp/guzzle/src/Exception/RequestException.
php:113 Stack trace: #0 /var/www/html/cb/vendor/guzzlehttp/guzzle/src/Middleware.php(65): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response)) #1 /var/www/html/cb/vendor/guzzlehttp/promises/src/Promise.php(203): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Response)) #2 /var/www/html/cb/vendor/guzzlehttp/promises/src/Promise.php(156): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), Array) #3 /var/www/html/cb/vendor/guzzlehttp/promises/src/TaskQueue.php(47): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}() #4 /var/www/html/cb/vendor/guzzlehttp/promises/src/Promise.php(246): GuzzleHttp\Promise\TaskQueue->run(true) #5 /var/www/html/cb/vendor/guzzlehttp/promises/src/Promise.p in /var/www/html/cb/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php on line 113
ни так ни сяк не хочет