ExternalResourceClient())->put Doesn't work as expected.

Hi, I was working in an integration with sharepoint API in sugarcrm version 12.X and curl functions. Unfortunately,  with the new update to 13.X curl functions were blacklisted, so the alternative is to use the src/Security/HttpClient/ExternalResourceClient.php library.

There is an option in the API in sharepoint where I need to create a container through an endpoint using "PUT" but in the examples in the documentation "PUT" doesn't have an example. Of course, the library or class file actually has a "PUT" method available.


This is part of a very simple script that works fine in a single file "temp.php" in the root directory of a sugarcrm v13.0 local instance. (In the same script I use curl functions and works fine.)

$Headers = array(
    'Content-Type: ' . $contentType,
    'Accept-Charset: ' . $encode,
    'Authorization: ' . $sp['token'],
    // 'Content-Length: ' . $bytes // curl works ok and generates a response with an "ID" if we omit this param.

$url1 = 'https://graph.microsoft.com/v1.0/sites/9f68e497-19f2-4bdc-bced-bfaf612e638b/drive/root:/DocumentRevisions/11111111-9397-11ee-ad5b-08002730cb32/libro_simulacion_mikroc_0.pdf:/content?Content-Type=application/pdf';

The $Headers array works in that way in curl headers but with ExternalResourceClient class raise an error:
TRIM  Argument #1 ($string) must be of type string, int given in /vagrant/rdev.merxbp.loc/src/Security/HttpClient/ExternalResourceClient.php:615
So I use an asociative array:
$Headers = array(
    'Content-Type' =>$contentType, 
    'Accept-Charset' => $encode,
    'Authorization' => $sp['token'], 

// Then i use the PUT method in this way:

$response = (new ExternalResourceClient())->put($url1,[], $Headers);
$resp = !empty($response) ? json_decode($response->getBody()->getContents(), true) : null;

But the response gives me:

Uncaught Sugarcrm\Sugarcrm\Security\HttpClient\RequestException: file_get_contents( Failed to open stream: HTTP request failed! in /vagrant/rdev.merxbp.loc/src/Security/HttpClient/ExternalResourceClient.php:379

Can you help me please?, what am i doing wrong?

Thanks in advance.