microsoftgraph / microsoftgraph/msgraph-sdk-php
Content type application/octet-stream does not have a factory to be parsed
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 669
- Forks
- 150
- Avg merge
- 15h 21m
- Merged PRs (30d)
- 3
Description
Describe the bug
Hi I am following this guide to export the docx file
Giving error "Content type application/octet-stream does not have a factory to be parsed"
` try {
Log::info("oneDrivePath " . $oneDrivePath);
// Get the source document ID
$docxDriveItemId = $this->getDriveItemIdByPath($oneDrivePath);
Log::info("Attempting to retrieve PDF content for DriveItem: " . $docxDriveItemId); // Log before the get
$requestConfiguration = new ContentRequestBuilderGetRequestConfiguration();
$queryParameters = ContentRequestBuilderGetRequestConfiguration::createQueryParameters();
$queryParameters->format = "pdf";
$requestConfiguration->queryParameters = $queryParameters;
// Get the PDF content by appending format=pdf to the request
$pdfContent = $this->graph->drives()
->byDriveId($this->drive_id)
->items()
->byDriveItemId($docxDriveItemId) // Append format parameter directly to ID
->content()
->get($requestConfiguration)
->wait();
...
`
can you please help where I am going wrong
Expected behavior
It should give pdf content
How to reproduce
use the php library
public function exportDocxToPdf($oneDrivePath, $oneDrivePDFPath): array | Exception
{
try {
Log::info("oneDrivePath " . $oneDrivePath);
// Get the source document ID
$docxDriveItemId = $this->getDriveItemIdByPath($oneDrivePath);
Log::info("Attempting to retrieve PDF content for DriveItem: " . $docxDriveItemId); // Log before the get
$requestConfiguration = new ContentRequestBuilderGetRequestConfiguration();
$queryParameters = ContentRequestBuilderGetRequestConfiguration::createQueryParameters();
$queryParameters->format = "pdf";
$requestConfiguration->queryParameters = $queryParameters;
// Get the PDF content by appending format=pdf to the request
$pdfContent = $this->graph->drives()
->byDriveId($this->drive_id)
->items()
// ->byDriveItemId($docxDriveItemId . '?format=pdf')
->byDriveItemId($docxDriveItemId) // Append format parameter directly to ID
->content()
->get($requestConfiguration)
->wait();
Log::info("PDF content retrieved successfully.");
} catch (\Exception $e) {
Log::error('Error exporting DOCX to PDF: ' , $e->getTrace() );
throw new Exception('Error exporting file to PDF: ' . $e->getMessage());
}
}
SDK Version
^2.24
Latest version known to work for scenario above?
^2.24
Known Workarounds
No response
Debug output
Click to expand log
```</details>
### Configuration
_No response_
### Other information
_No response_
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the PHP SDK v2.24 request in the issue, especially ContentRequestBuilderGetRequestConfiguration and the drives/items/content method chain. Reproduce the format=pdf request and trace where application/octet-stream is parsed. Done means determining whether the SDK or request handling causes the error and documenting or correcting the path to retrieve PDF content.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100