Graph Api 文件上传到 Sharepoint 图书馆 Json 格式错误

huangapple go评论72阅读模式
英文:

Graph Api File Upload to Sharepoint Library Json Format Error

问题

我试图从Power Apps使用此教程将一个简单的txt文档上传到SharePoint库。

我认为我操作正确,经过了很多权限问题的故障排除过程,但我卡在了这个错误上:

无法读取JSON请求负载。

我只是使用以下方式发送了一个PUT请求:

Office365Groups.HttpRequest(
    "https://graph.microsoft.com/v1.0/sites/{mySiteId}/drives/{myDriveId}/root:/file.txt:/content:",
    "PUT",
    ThisRecord.Value
)

mySiteIdmyDriveId 都是正确的。ThisRecord.Value 是附件字段中的文件内容。

如果我在Graph Explorer上尝试这个操作,我也会得到相同的结果。

文档中明确说明负载应为text/plain。

  • 如果文档要求text/plain负载,为什么要求JSON内容类型?
  • 有关如何继续前进的任何线索吗?
英文:

I'm trying to upload a simple txt document to a sharepoint library, from power apps, using this tutorial.

I think I'm doing it right, troubleshooted a lot of permissions issues trough the process, but I got stuck in this error:

Unabel to read JSON request payload.

I'm just sending a put request using this:

Office365Groups.HttpRequest(
        "https://graph.microsoft.com/v1.0/sites/{mySiteId}/drives/{myDriveId}/root:/file.txt:/content:",
        "PUT",
        ThisRecord.Value
    ) 

mySiteIdid and myDriveId, I got them both correct. ThisRecord.Value is the file content from the attachment field.

I also get the same result if I try this on the Graph Explorer.

It clearly states in the documentation, that the payload should be text/plain.

  • Why would it ask for a json content-type if the documentation states
    for a text/plain payload?
  • Any clues on how to move forward?

答案1

得分: 1

It works fine if you remove : of the URL

/v1.0/sites/{mySiteId}/drives/{myDriveId}/root:/file.txt:/content:
/v1.0/sites/{mySiteId}/drives/{myDriveId}/root:/file.txt:/content

I would also set the Content-Type parameter to text/plain

Office365Groups.HttpRequest(
"https://graph.microsoft.com/v1.0/sites/{mySiteId}/drives/{myDriveId}/root:/file.txt:/content",
"PUT",
ThisRecord.Value,
"text/plain"
)

Office 365 group - send HTTP request

英文:

It works fine if you remove : of the url

/v1.0/sites/{mySiteId}/drives/{myDriveId}/root:/file.txt:/content:
/v1.0/sites/{mySiteId}/drives/{myDriveId}/root:/file.txt:/content

I would also set the Content-Type parameter to text/plain

Office365Groups.HttpRequest(
    "https://graph.microsoft.com/v1.0/sites/{mySiteId}/drives/{myDriveId}/root:/file.txt:/content",
    "PUT",
    ThisRecord.Value,
    "text/plain"
) 

Office 365 group - send HTTP request

huangapple
  • 本文由 发表于 2023年8月4日 08:16:20
  • 转载请务必保留本文链接:https://go.coder-hub.com/76832264.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定