我想创建一个特定的作业类。
在Graph Explorer中,
https://graph.microsoft.com/beta/education/classes/{classId}/assignments这个请求运行得很好。
但在我的C#代码中,
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);发生错误:
{"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"}为什么会发生这种情况?我一整天都在思考和尝试。
我试过了
await graphClient.Education.Classes[pClassId].Assignments
.Request()
.Header("Content-Type", "application/json")
.AddAsync(assignInfo);但也有同样的错误。
如果只请求displayname元素,结果是相同的。
权限已经处理过了。EduAssignments.ReadWriteBasic,EduAssignments.ReadWrite..等和动态链接库(NuGet包)也是在测试版。
我指的是this document。
我迫切需要帮助..。谢谢。
发布于 2021-09-16 14:56:04
添加此assignInfo.ODataType = null;可以解决此问题。
https://stackoverflow.com/questions/63979137
复制相似问题