先决条件检查失败

Precondition check failed

我用Google课堂API已经有一段时间了,到现在为止一切顺利,但我想用setScheduledTime方法来发布公告,但没有用我我收到以下错误

Classroom service = new Classroom.Builder(HTTP_TRANSPORT, JSON_FACTORY, getCredentials(HTTP_TRANSPORT))
   .setApplicationName(APPLICATION_NAME)
   .build();

Classroom.Courses courses2 = service.courses();
Material a = new Material();
a.setDriveFile(pptx2);
List<Material> materialNames = new ArrayList<>();
materialNames.add(a);
Announcement announcement = new Announcement().setScheduledTime("2021-11-20T23:48:00Z").setText("New Announcement").setMaterials(materialNames);
courses2.announcements().create("426056383414", announcement).execute();

这是我遇到的错误

{
  "code" : 400,
  "errors" : [ {
    "domain" : "global",
    "message" : "Precondition check failed.",
    "reason" : "failedPrecondition"
  } ],
  "message" : "Precondition check failed.",
  "status" : "FAILED_PRECONDITION"
}

要为未来的时间戳安排公告,您需要将其当前 state 设置为 DRAFT:

Announcement announcement = new Announcement()setState("DRAFT").setScheduledTime("2021-11-20T23:48:00Z").setText("New Announcement").setMaterials(materialNames);