Google Classroom eklentileri artık geliştiricilerin genel kullanımına sunuldu! Daha fazla bilgi edinmek için lütfen
eklenti belgelerini inceleyin.
Ders davetlerini yönetme
Koleksiyonlar ile düzeninizi koruyun
İçeriği tercihlerinize göre kaydedin ve kategorilere ayırın.
Classroom'daki Invitation
kaynağı, kullanıcıların belirli bir kurs rolü (öğrenci, öğretmen veya sahip) ile kursa katılma davetini temsil eder.
Her Invitation
kaynağı aşağıdaki alanları içerir:
id
: Davetiye için Classroom tarafından atanan tanımlayıcı.
userId
: Kursa davet edilen kullanıcının kimliği.
courseId
: Kullanıcının davet edildiği kurs.
role
: Davet edilen kullanıcının kursta sahip olacağı kurs rolü.
Davetiye oluşturma
invitations.create()
yöntemi, belirli bir role sahip bir kullanıcıyı kursa davet etmek için kullanılabilir. İstek gövdesine Invitation
kaynağını ekleyin
ve courseId
, userId
ve role
değerlerini belirtin.
Davetiyeyi alma
invitations.get()
yöntemini çağırıp davetin id
değerini belirterek belirli bir daveti alın.
Daveti kabul etme
Daveti kabul ettiğinizde davet silinir ve davet edilen kullanıcı, davette belirtilen rolle kursa eklenir. invitations.accept()
yöntemini çağırıp davetin id
değerini belirterek daveti kabul edin.
Davetiyeyi silme
Davetiyeyi güncellemenin tek yolu, davetiyeyi silip yeni bir davetiye oluşturmaktır. Daveti silmek için invitations.delete()
yöntemini çağırın
ve id
değerini belirtin.
Aksi belirtilmediği sürece bu sayfanın içeriği Creative Commons Atıf 4.0 Lisansı altında ve kod örnekleri Apache 2.0 Lisansı altında lisanslanmıştır. Ayrıntılı bilgi için Google Developers Site Politikaları'na göz atın. Java, Oracle ve/veya satış ortaklarının tescilli ticari markasıdır.
Son güncelleme tarihi: 2025-08-01 UTC.
[null,null,["Son güncelleme tarihi: 2025-08-01 UTC."],[],[],null,["# Manage Course Invitations\n\nAn [`Invitation` resource](/workspace/classroom/reference/rest/v1/invitations) in Classroom represents an invitation\nfor a user to join a course with a specific [course role](/workspace/classroom/reference/rest/v1/invitations#courserole): student, teacher,\nor owner.\n\nEach `Invitation` resource contains the following fields:\n\n- `id`: Classroom-assigned identifier for the invitation.\n- `userId`: The ID of the user that has been invited to the course.\n- `courseId`: The course that the user is being invited to.\n- `role`: The [course role](/workspace/classroom/reference/rest/v1/invitations#courserole) that the invited user will have in the course.\n\nCreate an Invitation\n--------------------\n\nThe [`invitations.create()`](/workspace/classroom/reference/rest/v1/invitations/create) method can be used to invite a user to a course\nwith a specific role. Include the [`Invitation` resource](/workspace/classroom/reference/rest/v1/invitations) in the request body\nand specify the `courseId`, `userId`, and `role`. \n\n### Java\n\nclassroom/snippets/src/main/java/CreateInvitation.java \n[View on GitHub](https://github.com/googleworkspace/java-samples/blob/main/classroom/snippets/src/main/java/CreateInvitation.java) \n\n```java\nInvitation invitation = null;\ntry {\n /* Set the role the user is invited to have in the course. Possible values of CourseRole can be\n found here: https://developers.google.com/classroom/reference/rest/v1/invitations#courserole.*/\n Invitation content =\n new Invitation().setCourseId(courseId).setUserId(userId).setRole(\"TEACHER\");\n\n invitation = service.invitations().create(content).execute();\n\n System.out.printf(\n \"User (%s) has been invited to course (%s).\\n\",\n invitation.getUserId(), invitation.getCourseId());\n} catch (GoogleJsonResponseException e) {\n // TODO (developer) - handle error appropriately\n GoogleJsonError error = e.getDetails();\n if (error.getCode() == 404) {\n System.out.printf(\"The course or user does not exist.\\n\");\n }\n throw e;\n} catch (Exception e) {\n throw e;\n}\nreturn invitation;\n```\n\nRetrieve an Invitation\n----------------------\n\nRetrieve a specific invitation by calling the [`invitations.get()`](/workspace/classroom/reference/rest/v1/invitations/get) method\nand specifying the `id` of the invitation. \n\n### Java\n\nclassroom/snippets/src/main/java/GetInvitation.java \n[View on GitHub](https://github.com/googleworkspace/java-samples/blob/main/classroom/snippets/src/main/java/GetInvitation.java) \n\n```java\nInvitation invitation = null;\ntry {\n invitation = service.invitations().get(id).execute();\n System.out.printf(\n \"Invitation (%s) for user (%s) in course (%s) retrieved.\\n\",\n invitation.getId(), invitation.getUserId(), invitation.getCourseId());\n} catch (GoogleJsonResponseException e) {\n GoogleJsonError error = e.getDetails();\n if (error.getCode() == 404) {\n System.out.printf(\"The invitation id (%s) does not exist.\\n\", id);\n }\n throw e;\n} catch (Exception e) {\n throw e;\n}\nreturn invitation;\n```\n\nAccept an Invitation\n--------------------\n\nAccepting an invitation deletes the invitation and adds the invited\nuser to the course with the role specified in the invitation. Accept an\ninvitation by calling the [`invitations.accept()`](/workspace/classroom/reference/rest/v1/invitations/accept) method and specifying the\n`id` of the invitation. \n\n### Java\n\nclassroom/snippets/src/main/java/AcceptInvitation.java \n[View on GitHub](https://github.com/googleworkspace/java-samples/blob/main/classroom/snippets/src/main/java/AcceptInvitation.java) \n\n```java\ntry {\n service.invitations().accept(id).execute();\n System.out.printf(\"Invitation (%s) was accepted.\\n\", id);\n} catch (GoogleJsonResponseException e) {\n GoogleJsonError error = e.getDetails();\n if (error.getCode() == 404) {\n System.out.printf(\"The invitation id (%s) does not exist.\\n\", id);\n }\n throw e;\n} catch (Exception e) {\n throw e;\n}\n```\n\nDelete an Invitation\n--------------------\n\nThe only way to update an invitation is to delete it and create a new\ninvitation. To delete the invitation, call the [`invitations.delete()`](/workspace/classroom/reference/rest/v1/invitations/delete) method\nand specify the `id`. \n\n### Java\n\nclassroom/snippets/src/main/java/DeleteInvitation.java \n[View on GitHub](https://github.com/googleworkspace/java-samples/blob/main/classroom/snippets/src/main/java/DeleteInvitation.java) \n\n```java\ntry {\n service.invitations().delete(id).execute();\n System.out.printf(\"Invitation (%s) was deleted.\\n\", id);\n} catch (GoogleJsonResponseException e) {\n GoogleJsonError error = e.getDetails();\n if (error.getCode() == 404) {\n System.out.printf(\"The invitation id (%s) does not exist.\\n\", id);\n }\n throw e;\n} catch (Exception e) {\n throw e;\n}\n```"]]