Method: courses.courseWorkMaterials.addOnAttachments.create
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
יצירת קובץ מצורף של תוסף מתחת לפוסט.
נדרשת הרשאה לתוסף ליצור קבצים מצורפים חדשים בפוסט.
השיטה הזו מחזירה את קודי השגיאה הבאים:
PERMISSION_DENIED
עבור שגיאות גישה.
INVALID_ARGUMENT
אם הבקשה לא תקינה.
NOT_FOUND
אם אחד מהמשאבים שזוהו לא קיים.
בקשת HTTP
POST https://classroom.googleapis.com/v1/courses/{courseId}/courseWorkMaterials/{itemId}/addOnAttachments
כתובת ה-URL משתמשת בתחביר של Transcoding של gRPC.
פרמטרים של נתיב
פרמטרים |
courseId |
string
חובה. המזהה של הקורס.
|
itemId |
string
המזהה של Announcement , CourseWork או CourseWorkMaterial שבמסגרתו ייווצר הקובץ המצורף. השדה הזה הוא חובה, אבל הוא לא מסומן ככזה בזמן ההעברה מ-postId.
|
פרמטרים של שאילתה
פרמטרים |
postId (deprecated) |
string
אופציונלי. האפשרות הזו הוצאה משימוש. במקום זאת, צריך להשתמש ב-itemId .
|
addOnToken |
string
אופציונלי. אסימון שמאשר את הבקשה. האסימון מועבר כפרמטר של שאילתה כשהמשתמש מופנה מ-Classroom לכתובת ה-URL של התוסף. טוקן ההרשאה הזה נדרש ליצירת קבצים מצורפים ב-Classroom, אבל הוא אופציונלי ליצירת קבצים מצורפים שמוגדרים כ'שותף ראשי'. הפונקציה מחזירה שגיאה אם לא צוין פרמטר ליצירת קובץ מצורף בשביל השותף, ופרויקטי הפיתוח שבהם נוצר קובץ המצורף ופריט המקור שלו ב-Stream לא תואמים.
|
גוף הבקשה
גוף הבקשה מכיל מופע של AddOnAttachment
.
גוף התשובה
אם הפעולה בוצעה ללא שגיאות, גוף התגובה יכיל מופע חדש של AddOnAttachment
.
היקפי הרשאה
נדרש היקף הרשאות OAuth הבא:
https://www.googleapis.com/auth/classroom.addons.teacher
מידע נוסף זמין במדריך ההרשאות.
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 4.0 ודוגמאות הקוד הן ברישיון Apache 2.0. לפרטים, ניתן לעיין במדיניות האתר Google Developers. Java הוא סימן מסחרי רשום של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-07-25 (שעון UTC).
[null,null,["עדכון אחרון: 2025-07-25 (שעון UTC)."],[],[],null,["# Method: courses.courseWorkMaterials.addOnAttachments.create\n\n- [HTTP request](#body.HTTP_TEMPLATE)\n- [Path parameters](#body.PATH_PARAMETERS)\n- [Query parameters](#body.QUERY_PARAMETERS)\n- [Request body](#body.request_body)\n- [Response body](#body.response_body)\n- [Authorization scopes](#body.aspect)\n\nCreates an add-on attachment under a post.\n\nRequires the add-on to have permission to create new attachments on the post.\n\nThis method returns the following error codes:\n\n- `PERMISSION_DENIED` for [access errors](/workspace/classroom/reference/Access.Errors).\n- `INVALID_ARGUMENT` if the request is malformed.\n- `NOT_FOUND` if one of the identified resources does not exist.\n\n### HTTP request\n\n`POST https://classroom.googleapis.com/v1/courses/{courseId}/courseWorkMaterials/{itemId}/addOnAttachments`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\n### Path parameters\n\n| Parameters ||\n|------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `courseId` | `string` Required. Identifier of the course. |\n| `itemId` | `string` Identifier of the `Announcement`, `CourseWork`, or `CourseWorkMaterial` under which to create the attachment. This field is required, but is not marked as such while we are migrating from postId. |\n\n### Query parameters\n\n| Parameters ||\n|---------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `postId` **(deprecated)** | `string` Optional. Deprecated, use `itemId` instead. |\n| `addOnToken` | `string` Optional. Token that authorizes the request. The token is passed as a query parameter when the user is redirected from Classroom to the add-on's URL. This authorization token is required for in-Classroom attachment creation but optional for partner-first attachment creation. Returns an error if not provided for partner-first attachment creation and the developer projects that created the attachment and its parent stream item do not match. |\n\n### Request body\n\nThe request body contains an instance of [AddOnAttachment](/workspace/classroom/reference/rest/v1/courses.announcements.addOnAttachments#AddOnAttachment).\n\n### Response body\n\nIf successful, the response body contains a newly created instance of [AddOnAttachment](/workspace/classroom/reference/rest/v1/courses.announcements.addOnAttachments#AddOnAttachment).\n\n### Authorization scopes\n\nRequires the following OAuth scope:\n\n- `https://www.googleapis.com/auth/classroom.addons.teacher`\n\nFor more information, see the [Authorization guide](/workspace/guides/configure-oauth-consent)."]]