Issue
it is been a while I use Google Classroom API till now it went so well, but I want to use setScheduledTime
method for the announcement but didn't work I am getting the following error
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();
This is the error I'm getting
{
"code" : 400,
"errors" : [ {
"domain" : "global",
"message" : "Precondition check failed.",
"reason" : "failedPrecondition"
} ],
"message" : "Precondition check failed.",
"status" : "FAILED_PRECONDITION"
}
Solution
To schedule an announcement for a future timestamp, you need to set it's current state
to DRAFT
:
Announcement announcement = new Announcement()setState("DRAFT").setScheduledTime("2021-11-20T23:48:00Z").setText("New Announcement").setMaterials(materialNames);
Answered By - ziganotschka
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.