首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Microsoft Graph Api - Create Education Assignment返回"20132“错误

Microsoft Graph Api - Create Education Assignment返回"20132“错误
EN

Stack Overflow用户
提问于 2020-09-20 20:46:58
回答 1查看 75关注 0票数 2

我想创建一个特定的作业类。

在Graph Explorer中,

代码语言:javascript
复制
https://graph.microsoft.com/beta/education/classes/{classId}/assignments

这个请求运行得很好。

但在我的C#代码中,

代码语言:javascript
复制
var assignInfo = new EducationAssignment
            {

                DisplayName = "test",
                
                DueDateTime = DateTimeOffset.Parse("2020-09-20T18:00:00Z"),
                Instructions = new EducationItemBody
                {
                    ContentType = BodyType.Html,
                    Content = "hi"
                },
                Status = EducationAssignmentStatus.Draft,
                AllowStudentsToAddResourcesToSubmission = true,
                
                AssignTo = new EducationAssignmentClassRecipient
                {

                },
                Grading = new EducationAssignmentPointsGradeType()
                {
                    MaxPoints = 100
                },
                CreatedDateTime = DateTimeOffset.Parse("2020-09-20T12:00:00Z"),
                AssignDateTime = DateTimeOffset.Parse("2020-09-20T13:00:00Z"),
                AssignedDateTime = DateTimeOffset.Parse("2020-09-20T13:00:00Z"),
                
                CloseDateTime = null,
                
                AllowLateSubmissions = true
                
            };

             await graphClient.Education.Classes[pClassId].Assignments
                .Request()
                
                .AddAsync(assignInfo);

发生错误:

代码语言:javascript
复制
{"Code: 20132\r\nMessage: The content of the request is invalid. Common causes are an invalid Content-Type header or no content in the body.\r\nInner error:\r\n\tAdditionalData:\r\n\tdate: 2020-09-20T07:25:14\r\n\trequest-id: d2181119-9116-4f1d-9ed4-d007e2e406d0\r\n\tclient-request-id: d2181119-9116-4f1d-9ed4-d007e2e406d0\r\nClientRequestId: d2181119-9116-4f1d-9ed4-d007e2e406d0\r\n"}

为什么会发生这种情况?我一整天都在思考和尝试。

我试过了

代码语言:javascript
复制
 await graphClient.Education.Classes[pClassId].Assignments
                .Request()
                .Header("Content-Type", "application/json")
                .AddAsync(assignInfo);

但也有同样的错误。

如果只请求displayname元素,结果是相同的。

权限已经处理过了。EduAssignments.ReadWriteBasic,EduAssignments.ReadWrite..等和动态链接库(NuGet包)也是在测试版。

我指的是this document

我迫切需要帮助..。谢谢。

EN

回答 1

Stack Overflow用户

发布于 2021-09-16 14:56:04

添加此assignInfo.ODataType = null;可以解决此问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63979137

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档