ส่วนเสริมของ Google Classroom พร้อมให้บริการแก่นักพัฒนาซอฟต์แวร์แล้ว โปรดดูข้อมูลเพิ่มเติมใน
เอกสารส่วนเสริม
Method: courses.announcements.addOnAttachments.create
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
สร้างไฟล์แนบของส่วนเสริมใต้โพสต์
กำหนดให้ส่วนเสริมต้องมีสิทธิ์สร้างไฟล์แนบใหม่ในโพสต์
วิธีการนี้จะแสดงรหัสข้อผิดพลาดต่อไปนี้
PERMISSION_DENIED
สำหรับข้อผิดพลาดในการเข้าถึง
INVALID_ARGUMENT
หากคำขอมีรูปแบบไม่ถูกต้อง
NOT_FOUND
หากทรัพยากรที่ระบุไม่อยู่
คำขอ HTTP
POST https://classroom.googleapis.com/v1/courses/{courseId}/announcements/{itemId}/addOnAttachments
URL ใช้ไวยากรณ์การแปลง gRPC
พารามิเตอร์เส้นทาง
พารามิเตอร์ |
courseId |
string
ต้องระบุ ตัวระบุของหลักสูตร
|
itemId |
string
ตัวระบุของ Announcement , CourseWork หรือ CourseWorkMaterial ที่จะสร้างไฟล์แนบ คุณต้องกรอกข้อมูลในช่องนี้ แต่ไม่ได้ระบุว่าเป็นช่องที่ต้องกรอกขณะที่เราย้ายข้อมูลจาก postId
|
พารามิเตอร์การค้นหา
พารามิเตอร์ |
postId (deprecated) |
string
ไม่บังคับ เลิกใช้งานแล้ว โปรดใช้ itemId แทน
|
addOnToken |
string
ไม่บังคับ โทเค็นที่ให้สิทธิ์คําขอ ระบบจะส่งโทเค็นเป็นพารามิเตอร์การค้นหาเมื่อระบบเปลี่ยนเส้นทางผู้ใช้จาก Classroom ไปยัง URL ของส่วนเสริม โทเค็นการให้สิทธิ์นี้จำเป็นสำหรับการสร้างไฟล์แนบใน Classroom แต่ไม่จำเป็นต้องใช้สำหรับการสร้างไฟล์แนบแบบพาร์ทเนอร์ก่อน แสดงข้อผิดพลาดหากไม่ได้ระบุสำหรับการสร้างไฟล์แนบของพาร์ทเนอร์เป็นอันดับแรก และโปรเจ็กต์ของนักพัฒนาแอปที่สร้างไฟล์แนบและรายการสตรีมหลักของไฟล์แนบไม่ตรงกัน
|
เนื้อความของคำขอ
เนื้อความของคำขอมีอินสแตนซ์ของ AddOnAttachment
เนื้อหาการตอบกลับ
หากทำสำเร็จ เนื้อหาการตอบกลับจะมีอินสแตนซ์ AddOnAttachment
ที่สร้างขึ้นใหม่
ขอบเขตการให้สิทธิ์
ต้องใช้ขอบเขต OAuth ต่อไปนี้
https://www.googleapis.com/auth/classroom.addons.teacher
ดูข้อมูลเพิ่มเติมได้ที่คู่มือการให้สิทธิ์
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-25 UTC
[null,null,["อัปเดตล่าสุด 2025-07-25 UTC"],[],[],null,["# Method: courses.announcements.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}/announcements/{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)."]]