Skip to content

How to use courses.courseWork.addOnAttachments resource? #3529

Open

Description

@MuhamadIsmuaji

Hello everyone may I ask how I can use courses.courseWork.addOnAttachments resource with this lib? I've installed the lib with yarn install googleapis with version 140.0.1 or yarn install @googleapis/classroom with version 4.0.9. But somehow I can't use like google.classroom({ version: 'v1' }).courses.courseWork.addOnAttachments.create() ? I've see in this repo there is addOnAttachments in this code . But somehow when I've install the lib, I can't find that code

Activity

  1. added
    priority: p3Desirable enhancement or fix. May not be included in next release.
    type: questionRequest for information or clarification. Not an issue.
    on Jul 29, 2024
  2. lukesanborn commented on Jul 29, 2024

    @lukesanborn

    I'm having the same problem too. Google API clients are automatically generated from a discovery JSON file. Google must periodically re-generate each client library and push to the respective package manager, npm, pypi etc. For example, the Python client API was regenerated a few weeks ago and includes Google Classroom Add-on functionality. The nodejs client library has not been regenerated with these new classroom changes. I've found a workaround to get these working locally if you're interested.

    Google if you are seeing this, please update the npm package 🙏

  3. MuhamadIsmuaji commented on Jul 29, 2024

    @MuhamadIsmuaji
    Author

    I'm having the same problem too. Google API clients are automatically generated from a discovery JSON file. Google must periodically re-generate each client library and push to the respective package manager, npm, pypi etc. For example, the Python client API was regenerated a few weeks ago and includes Google Classroom Add-on functionality. The nodejs client library has not been regenerated with these new classroom changes. I've found a workaround to get these working locally if you're interested.

    Google if you are seeing this, please update the npm package 🙏

    Hi @lukesanborn thanks for the response. Yep I'm interested for how it can working locally, could you please let me know?

  4. lukesanborn commented on Jul 29, 2024

    @lukesanborn

    Workaround steps:
    Clone git repo -> google-api-nodejs-client/generator.md at main · googleapis/google-api-nodejs-client (github.com)
    cd google-api-nodejs && npm i
    ** important check to make sure you have the right discovery file

    node build/src/generator/generator.js 'https://classroom.googleapis.com/$discovery/rest' \ --include-private false \ --use-cache false

    After generating the API, install the package
    cd src/apis/classroom
    Npm i && npm pack
    That should create “googleapis-classroom-4.0.9.tgz”
    Then move the file to your source code
    Add this line to the package. json file
    "classroom-with-addon": "file:./googleapis-classroom-4.0.9.tgz",
    Run npm i and now should work :)))

  5. MuhamadIsmuaji commented on Jul 29, 2024

    @MuhamadIsmuaji
    Author

    Also @lukesanborn maybe you know about this problem as well, I've try to issue request using Axios. Somehow I always got error below
    { "error": { "code": 403, "message": "@ProjectPermissionDenied The Developer Console project is not permitted to make this request.", "status": "PERMISSION_DENIED" } }

    So what I've done is try to create attachment with issue POST request with Axios to https://classroom.googleapis.com/v1/courses/${courseId}/courseWork/${itemId}/addOnAttachments. I use axios config headers below

    headers: { "Content-Type": "application/json", Authorization:Bearer ${accessToken}, },
    I use OAuth 2.0 credentials and I've make sure all scopes already configured

  6. MuhamadIsmuaji commented on Jul 29, 2024

    @MuhamadIsmuaji
    Author

    Btw thanks for the workaround steps @lukesanborn , let me try it

  7. lukesanborn commented on Jul 29, 2024

    @lukesanborn

    Have you enabled the Google Classroom API in the Cloud console? @MuhamadIsmuaji

  8. MuhamadIsmuaji commented on Jul 29, 2024

    @MuhamadIsmuaji
    Author

    Yes @lukesanborn , Google Classroom API already enabled. Additional information, I can issue GET request with Axios with same config to https://classroom.googleapis.com/v1/courses

  9. lukesanborn commented on Jul 30, 2024

    @lukesanborn

    @sofisl When will the package be updated on npm?

  10. nottisa commented on Sep 27, 2025

    @nottisa

    Same issue with customer.devices.chromeos.batchChangeStatus

    export class Resource$Customer$Devices$Chromeos {
    context: APIRequestContext;
    commands: Resource$Customer$Devices$Chromeos$Commands;
    constructor(context: APIRequestContext) {
    this.context = context;
    this.commands = new Resource$Customer$Devices$Chromeos$Commands(
    this.context
    );
    }
    /**
    * Changes the status of a batch of ChromeOS devices. For more information about changing a ChromeOS device state [Repair, repurpose, or retire ChromeOS devices](https://support.google.com/chrome/a/answer/3523633).
    * @example
    * ```js
    * // Before running the sample:
    * // - Enable the API at:
    * // https://console.developers.google.com/apis/api/admin.googleapis.com
    * // - Login into gcloud by running:
    * // ```sh
    * // $ gcloud auth application-default login
    * // ```
    * // - Install the npm module by running:
    * // ```sh
    * // $ npm install googleapis
    * // ```
    *
    * const {google} = require('googleapis');
    * const admin = google.admin('directory_v1');
    *
    * async function main() {
    * const auth = new google.auth.GoogleAuth({
    * // Scopes can be specified either as an array or as a single, space-delimited string.
    * scopes: ['https://www.googleapis.com/auth/admin.directory.device.chromeos'],
    * });
    *
    * // Acquire an auth client, and bind it to all future calls
    * const authClient = await auth.getClient();
    * google.options({auth: authClient});
    *
    * // Do the magic
    * const res = await admin.customer.devices.chromeos.batchChangeStatus({
    * // Required. Immutable ID of the Google Workspace account.
    * customerId: 'placeholder-value',
    *
    * // Request body metadata
    * requestBody: {
    * // request body parameters
    * // {
    * // "changeChromeOsDeviceStatusAction": "my_changeChromeOsDeviceStatusAction",
    * // "deprovisionReason": "my_deprovisionReason",
    * // "deviceIds": []
    * // }
    * },
    * });
    * console.log(res.data);
    *
    * // Example response
    * // {
    * // "changeChromeOsDeviceStatusResults": []
    * // }
    * }
    *
    * main().catch(e => {
    * console.error(e);
    * throw e;
    * });
    *
    * ```
    *
    * @param params - Parameters for request
    * @param options - Optionally override request options, such as `url`, `method`, and `encoding`.
    * @param callback - Optional callback that handles the response.
    * @returns A promise if used with async/await, or void if used with a callback.
    */
    batchChangeStatus(
    params: Params$Resource$Customer$Devices$Chromeos$Batchchangestatus,
    options: StreamMethodOptions
    ): Promise<GaxiosResponseWithHTTP2<Readable>>;
    batchChangeStatus(
    params?: Params$Resource$Customer$Devices$Chromeos$Batchchangestatus,
    options?: MethodOptions
    ): Promise<
    GaxiosResponseWithHTTP2<Schema$BatchChangeChromeOsDeviceStatusResponse>
    >;
    batchChangeStatus(
    params: Params$Resource$Customer$Devices$Chromeos$Batchchangestatus,
    options: StreamMethodOptions | BodyResponseCallback<Readable>,
    callback: BodyResponseCallback<Readable>
    ): void;
    batchChangeStatus(
    params: Params$Resource$Customer$Devices$Chromeos$Batchchangestatus,
    options:
    | MethodOptions
    | BodyResponseCallback<Schema$BatchChangeChromeOsDeviceStatusResponse>,
    callback: BodyResponseCallback<Schema$BatchChangeChromeOsDeviceStatusResponse>
    ): void;
    batchChangeStatus(
    params: Params$Resource$Customer$Devices$Chromeos$Batchchangestatus,
    callback: BodyResponseCallback<Schema$BatchChangeChromeOsDeviceStatusResponse>
    ): void;
    batchChangeStatus(
    callback: BodyResponseCallback<Schema$BatchChangeChromeOsDeviceStatusResponse>
    ): void;
    batchChangeStatus(
    paramsOrCallback?:
    | Params$Resource$Customer$Devices$Chromeos$Batchchangestatus
    | BodyResponseCallback<Schema$BatchChangeChromeOsDeviceStatusResponse>
    | BodyResponseCallback<Readable>,
    optionsOrCallback?:
    | MethodOptions
    | StreamMethodOptions
    | BodyResponseCallback<Schema$BatchChangeChromeOsDeviceStatusResponse>
    | BodyResponseCallback<Readable>,
    callback?:
    | BodyResponseCallback<Schema$BatchChangeChromeOsDeviceStatusResponse>
    | BodyResponseCallback<Readable>
    ):
    | void
    | Promise<
    GaxiosResponseWithHTTP2<Schema$BatchChangeChromeOsDeviceStatusResponse>
    >
    | Promise<GaxiosResponseWithHTTP2<Readable>> {
    let params = (paramsOrCallback ||
    {}) as Params$Resource$Customer$Devices$Chromeos$Batchchangestatus;
    let options = (optionsOrCallback || {}) as MethodOptions;
    if (typeof paramsOrCallback === 'function') {
    callback = paramsOrCallback;
    params =
    {} as Params$Resource$Customer$Devices$Chromeos$Batchchangestatus;
    options = {};
    }
    if (typeof optionsOrCallback === 'function') {
    callback = optionsOrCallback;
    options = {};
    }
    const rootUrl = options.rootUrl || 'https://admin.googleapis.com/';
    const parameters = {
    options: Object.assign(
    {
    url: (
    rootUrl +
    '/admin/directory/v1/customer/{customerId}/devices/chromeos:batchChangeStatus'
    ).replace(/([^:]\/)\/+/g, '$1'),
    method: 'POST',
    apiVersion: '',
    },
    options
    ),
    params,
    requiredParams: ['customerId'],
    pathParams: ['customerId'],
    context: this.context,
    };
    if (callback) {
    createAPIRequest<Schema$BatchChangeChromeOsDeviceStatusResponse>(
    parameters,
    callback as BodyResponseCallback<unknown>
    );
    } else {
    return createAPIRequest<Schema$BatchChangeChromeOsDeviceStatusResponse>(
    parameters
    );
    }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: p3Desirable enhancement or fix. May not be included in next release.type: questionRequest for information or clarification. Not an issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions