microsoftgraph / microsoftgraph/msgraph-sdk-php

Content type application/octet-stream does not have a factory to be parsed

Abierto
#1,650 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

status:waiting-for-triage type:bug
Lenguaje dominante
PHP
Estrellas
669
Forks
150
Merge medio
15 h 21 min
PR fusionados (30 d)
3

Descripción

Describe the bug

Hi I am following this guide to export the docx file

https://learn.microsoft.com/en-us/graph/api/driveitem-get-content-format?view=graph-rest-1.0&tabs=php#query-parameters

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_

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Empiece con la solicitud de PHP SDK v2.24 del issue, especialmente con ContentRequestBuilderGetRequestConfiguration y la cadena de métodos drives/items/content. Reproduzca la solicitud format=pdf y rastree dónde se analiza application/octet-stream. Se considera terminado determinar si el SDK o el procesamiento de solicitudes causa el error y documentar o corregir la ruta para recuperar contenido PDF.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
php
Área
api
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Necesita aclaración
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.