microsoftgraph / microsoftgraph/msgraph-sdk-php
Content type application/octet-stream does not have a factory to be parsed
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- PHP
- Sterne
- 669
- Forks
- 150
- Ø Merge
- 15 Std. 21 Min.
- Gemergte PRs (30 T.)
- 3
Beschreibung
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_
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginnen Sie mit der PHP SDK v2.24-Anfrage im Issue, insbesondere mit ContentRequestBuilderGetRequestConfiguration und der drives/items/content-Methodenkette. Reproduzieren Sie die format=pdf-Anfrage und verfolgen Sie, wo application/octet-stream geparst wird. Als erledigt gilt, festzustellen, ob das SDK oder die Anfrageverarbeitung den Fehler verursacht, und den Pfad zum Abrufen von PDF-Inhalten zu dokumentieren oder zu korrigieren.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- php
- Bereich
- api
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 35/100