Google Vision API - Invalid JSON payload received. Unable to parse number
<p>I was working with google Vision API.</p>

<p>When I curl in command line it gives me status 200 OK with the following command:</p>

<pre><code>curl -v -k -s -H "Content-Type: application/json" https://vision.googleapis.com/v1/images:annotate?key=API_KEY --data-binary @base64.json
</code></pre>

<p>But when I use it with PHP, I get an return message:</p>

<p>{ "error": { "code": 400, "message": "Invalid JSON payload received. Unable to parse number.\n--------------------\n^", "status": "INVALID_ARGUMENT" } }</p>

<pre><code>try {
$post = array(
    'file' =&gt; '@base64.json'
);

$ch = curl_init('https://vision.googleapis.com/v1/images:annotate?key=API_KEY');
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    $content = curl_exec($ch);

    if (FALSE === $content)
        throw new Exception(curl_error($ch), curl_errno($ch));

    curl_close($ch);  // Seems like good practice
    return $content;
} catch (Exception $e) {
    trigger_error(sprintf(
        'Curl failed with error #%d: %s',
        $e-&gt;getCode(), $e-&gt;getMessage()),
        E_USER_ERROR);
}
</code></pre>

<p>I was following this example:</p>

<p><a href="https://cloud.google.com/vision/docs/getting-started" rel="nofollow">https://cloud.google.com/vision/docs/getting-started</a></p>