Post content via JSON API: CURL works, PHP not?
The 401 error is because you're not sending the basic auth creds like you are with your curl request. You need to add an Authorization header to your Guzzle request:
'Authorization' =&gt; 'Basic ' . base64_encode($user . ':' . $pass),
The 500 error is likely due to a malformed payload that JSONAPI can't parse. The value of json should be an associative array, not a JSON encoded string. See the Guzzle docs on uploading JSON data.