GuzzleHttp give me 500 error
<p>I try to use GuzzleHttp with Magento to update my product catalog.</p>

<p>I use a pool request to get data from database and I try to post them into magento trought API</p>

<pre><code>$apiUrl = 'http://xxx.xxxxx.xxx';

$middleware = new Oauth1([
    'consumer_key'    =&gt; '-------------------------------',
    'consumer_secret' =&gt; '-------------------------------',
    'token'           =&gt; '-------------------------------',
    'token_secret'    =&gt; '-------------------------------'
]);
$stack-&gt;push($middleware);


$client = new Client();

$clientUpdate = new Client([
    'base_uri' =&gt; $apiUrl,
    'handler' =&gt; $stack,
    'auth' =&gt; 'oauth'
]);

$mapper = new JsonMapper();



$requests = function ($total) {
    $uri = 'http://10.0.0.114:15021/myservice';

    for ($i = 1; $i &lt;= $total; $i++) {
        yield new Request('GET', $uri.$i);
    }
};

$pool = new Pool($client, $requests(3), [
    'concurrency' =&gt; 3,
    'fulfilled' =&gt; function ($response, $index) {

        global $clientUpdate, $mapper;

        $productsArray = $mapper-&gt;mapArray(
            json_decode($response-&gt;getBody($asString = TRUE)), new ArrayObject(), 'ProductGo'
        );

        $product = new Product();
        $stock = new StockData();

        foreach($productsArray as &amp;$value){

            $product-&gt;type_id = "simple";
            $product-&gt;attribute_set_id = 4;
            $product-&gt;sku = $value-&gt;xxxxxxxxxxxxxxx;
            $product-&gt;weight = 1;
            $product-&gt;name = $value-&gt;xxxxxxxx;
            $product-&gt;price = $value-&gt;xxxxxxxx;
            $product-&gt;status = 1;
            $product-&gt;visibility =4;
            $product-&gt;tax_class_id = 4;
            $product-&gt;description = $value-&gt;xxxxxxx;
            $product-&gt;short_description = $value-&gt;xxxxxx;

            $stock-&gt;qty = $value-&gt;xxxxx;
            $stock-&gt;min_qty = "0";
            $stock-&gt;is_qty_decimal = 0;
            $stock-&gt;is_in_stock = 1;

            $product-&gt;stock_data = (object) array_filter((array) $stock);

            $productIn = (object) array_filter((array) $product);
            try{
                $response = $clientUpdate-&gt;request('POST', '/api/rest/products', ['json' =&gt; json_encode($productIn)]);

                echo $response;
            }catch (RequestException $e) {
                echo GuzzleHttp\Psr7\str($e-&gt;getRequest());
                if ($e-&gt;hasResponse()) {
                    echo GuzzleHttp\Psr7\str($e-&gt;getResponse());
                }
            }

        }
    },
    'rejected' =&gt; function ($reason, $index) {
       echo $reason;
    },
]);

// Initiate the transfers and create a promise
$promise = $pool-&gt;promise();

// Force the pool of requests to complete.
$promise-&gt;wait();
</code></pre>

<p>Pool request works ok. If I debug I will put a break point where I make a request but after I get ever the same error</p>

<pre><code>PHP Fatal error:  Uncaught exception 'GuzzleHttp\Exception\ServerException' with message 'Server error: 500' in /home/xxxxxxxxxxx/PhpstormProjects/xxxxxxxxxxx/vendor/guzzlehttp/guzzle/src/Middleware.php:68
Stack trace:
#0 /home/xxxxxxxxxxx/PhpstormProjects/xxxxxxxxxxx/vendor/guzzlehttp/promises/src/Promise.php(199): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Response))
#1 /home/xxxxxxxxxxx/PhpstormProjects/xxxxxxxxxxx/vendor/guzzlehttp/promises/src/Promise.php(152): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), Array)
#2 /home/xxxxxxxxxxx/PhpstormProjects/xxxxxxxxxxx/vendor/guzzlehttp/promises/src/TaskQueue.php(60): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}()
#3 /home/xxxxxxxxxxx/PhpstormProjects/xxxxxxxxxxx/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php(96): GuzzleHttp\Promise\TaskQueue-&gt;run()
#4 /home/xxxxxxxxxxx/PhpstormProjects/xxxxxxxxxxx/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php(123): GuzzleHttp\Handler\CurlMultiHandler-&gt;tick()
#5 /home/xxxxxxxxxxx/PhpstormPr in /home/xxxxxxxxxxx/PhpstormProjects/xxxxxxxxxxx/vendor/guzzlehttp/guzzle/src/Middleware.php on line 68
</code></pre>

<p>I can't understand what's the problem, I've tried to post with postman this json as product and it works.</p>

<p>Any suggestions???</p>