[microsoft-graph-php] Unable to send large attachment: LargeFileUploadTask and headers

Tomáš Najman 0 Reputation points
2026-07-21T05:54:33.6933333+00:00

Unable to upload large attachment. In the file Microsoft\Kiota\Abstractions\RequestHeaders, the array_keys function is used, which returns keys as a number. This is a problem in the Microsoft Graph Library for PHP.

The getAll method returns an error: Since guzzlehttp/psr7 2.11: Passing int to GuzzleHttp\Psr7\Request::__construct() is deprecated; guzzlehttp/psr7 3.0 requires string|string[].

You must use foreach instead of array_keys. PHP internally casts text keys that look like numbers.

For more information, see: https://github.com/microsoftgraph/msgraph-sdk-php/issues/1794

Microsoft 365 and Office | Development | Other
0 comments No comments

2 answers

Sort by: Most helpful
  1. Teddie-D 19,760 Reputation points Microsoft External Staff Moderator
    2026-07-21T06:45:19.2266667+00:00

    Hi @Tomáš Najman

    Thank you for raising this issue and for taking the time to report it on the Microsoft Graph PHP GitHub repository.

    Based on the discussion in the referenced PHP issue, the PHP developers have confirmed that this is expected language behavior. Numeric string array keys are automatically converted to integers when the array is created, and array_keys() simply returns the keys as they exist. The issue has been closed as not planned, as changing this behavior would introduce a significant backward compatibility break.

    Since you've already reported this to the Microsoft Graph PHP SDK repository and that issue has now been closed as not planned, there isn't anything further we can confirm from the Microsoft Q&A forum. This forum is intended for product support and documentation guidance, while design decisions and code changes for the SDK are handled by the maintainers on GitHub.

    Thank you for your understanding.


    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.  

    Was this answer helpful?

    0 comments No comments

  2. Hamza Raja 0 Reputation points
    2026-07-21T06:05:43.88+00:00

    PHP automatically casts string keys containing only numbers (e.g., "123") to integer 123. Passing an int key to Guzzle triggers a type error/deprecation warning in guzzlehttp/psr7.

    Solution

    Cast keys explicitly to string using foreach instead of relying on array_keys():

    PHP

    public function getAll(): array
    {
        $result = [];
        foreach ($this->headers as $key => $value) {
            $result[(string) $key] = $value;
        }
        return $result;
    }
    

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.