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

未关闭
#1,650 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
技术栈
php
领域
api

调研方向

从 issue 中的 PHP SDK v2.24 请求开始,重点关注 ContentRequestBuilderGetRequestConfiguration 和 drives/items/content 方法链。重现 format=pdf 请求,并跟踪 application/octet-stream 在何处被解析。完成标准是确定错误由 SDK 还是请求处理导致,并记录或修正获取 PDF 内容的路径。

由索引模型根据 Issue 内容生成。

描述

status:waiting-for-triage type:bug
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_
主要语言
PHP
星标
669
派生
149
平均合并
1 天 4 小时
30 天内合并 PR
5

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

microsoftgraph/msgraph-sdk-php 的其他 Issue

查看 microsoftgraph/msgraph-sdk-php 的全部 Issue

相似的 Issue

更多 PHP Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。