Skip to content

Introduce util for retrieving graph site id from webUrl #4316

@MathijsVerbeeck

Description

@MathijsVerbeeck

Currently, we have multiple commands using the method getSpoSiteId. These methods all have the same functionallty. The code is the following:

private async getSpoSiteId(args: CommandArgs): Promise<string> {
    const url = new URL(args.options.webUrl!);
    const requestOptions: CliRequestOptions= {
      url: `${this.resource}/v1.0/sites/${url.hostname}:${url.pathname}`,
      headers: {
        accept: 'application/json;odata.metadata=none'
      },
      responseType: 'json'
    };

    const site = await request.get<{ id: string }>(requestOptions)
    return site.id!
}

As this code is reused multiple times, it would be handy if this code is added to a util such as aadGroup.

This method is currently used in the following commands:

  • onenote notebook list
  • onenote page list (new command, still to be merged)
  • spo site apppermission add
  • spo site apppermission get
  • spo site apppermission list
  • spo site apppermission remove
  • spo site apppermission set

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions