microsoftgraph / microsoftgraph/msgraph-sdk-php

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

オープン
#1,650 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

status:waiting-for-triage type:bug
主要言語
PHP
スター
669
フォーク
150
平均マージ
15時間 21分
マージ済み PR(30日)
3

説明

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_

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

Issue の PHP SDK v2.24 リクエストから始め、特に ContentRequestBuilderGetRequestConfiguration と drives/items/content メソッドチェーンを確認します。format=pdf リクエストを再現し、application/octet-stream がどこで解析されるかを追跡します。SDK とリクエスト処理のどちらがエラーの原因かを特定し、PDF コンテンツを取得するためのパスを文書化または修正できれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
php
領域
api
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。