microsoftgraph / microsoftgraph/msgraph-sdk-php
Content type application/octet-stream does not have a factory to be parsed
Nessuno ha ancora preso questa issue.
- Lingua principale
- PHP
- Stelle
- 669
- Fork
- 150
- Merge medio
- 15h 21m
- PR unite (30g)
- 3
Descrizione
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_
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Iniziate dalla richiesta PHP SDK v2.24 nell’issue, in particolare da ContentRequestBuilderGetRequestConfiguration e dalla catena di metodi drives/items/content. Riproducete la richiesta format=pdf e tracciate il punto in cui viene analizzato application/octet-stream. Il lavoro è completo quando viene determinato se l’errore è causato dall’SDK o dalla gestione della richiesta e viene documentato o corretto il percorso per recuperare il contenuto PDF.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- php
- Ambito
- api
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 35/100