Problem with the users/edituser command in Provisioning API using PHP-curl

Problem with the users/edituser command in Provisioning API using PHP-curl

The following command works fine. It adds an emailaddress to the user "testuser".

curl -X PUT --user "youradminname:adminpasswd" http://yourowncloudhost/owncloud/ocs/v1.php/cloud/users/testuser -d key="email" -d value="testuseremailaddress"

However, working with php-curl (see below), I get as "response" an error 997. Is it a bug in PHP-curl or ..??
I've seen the items in the old forum concerning this: #14283 and #20212. I'm not sure they are solved yet...

$userName = 'testuser';
$emailaddress = "your.email@provider.com";
$ownAdminname = 'youradminname';
$ownAdminpassword = 'adminpasswd';
$url = 'http://yourowncloudhost/owncloud/ocs/v1.php/cloud/users/'.$userName;
$ownCloudPOSTArray = array('key' => "email", 'value' => $emailaddress);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POSTFIELDS, $ownCloudPOSTArray);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, "$ownAdminname:$ownAdminpassword");
$response = curl_exec($ch);
if ($response === FALSE) {
	printf("curl error (#%d): %s<br>\n", curl_errno($ch), htmlspecialchars(curl_error($ch)));
	}
curl_close($ch);
echo "Response from curl (adding emailaddress):" . $response;

I'm having the exact same issue and exposed it on GitHub (https://github.com/owncloud/core/issues/27976.
Did you find any solution on this??