Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds m365 spo tenant homesite add. Closes #6488 #6533

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

reshmee011
Copy link
Contributor

Closes #6488

New Command = Five Files

  • src/m365/spo/commands.ts
  • src/m365/spo/commands/tenant/tenant-homesite-add.ts
  • src/m365/spo/commands/tenant/tenant-homesite-add.spec.ts
  • docs/src/config/sidebars.js
  • docs/docs/cmd/spo/tenant/tenant-homesite-add.mdx

@milanholemans
Copy link
Contributor

Thank you @reshmee011, we'll have a look at it soon!

@milanholemans milanholemans self-assigned this Jan 2, 2025
try {
const spoAdminUrl: string = await spo.getSpoAdminUrl(logger, this.verbose);
const requestOptions: CliRequestOptions = {
url: `${spoAdminUrl}/_api/SPO.Tenant/AddHomeSite`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @reshmee011, I've noticed in this command, we can only provide the URL of the home site, and nothing else. What I'm missing here, are the other properties like isInDraftMode, vivaConnectionsDefaultStart etc that cannot be set with this API request (or am I wrong here?) Currently, if we want to set these options, we'll have to execute a separate command, which is annoying of course. Do you know whether it's possible to provide the extra options?

I found following request, which is capable of doing so:

POST https://contoso-admin.sharepoint.com/_api/SPHSite/AddHomeSite
{
    "siteUrl": "https://contoso.sharepoint.com/sites/homesite",
    "audiences": ["<audiences>"],
    "vivaConnectionsDefaultStart": false,
    "isInDraftMode": false
}

Maybe we should roll with this one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, I will check if those additional parameters: isInDraftMode, vivaConnectionsDefaultStart work with the endpoint AddHomeSite. Have you tried them out?
Definitely those can be passed to the endpoint /_api/SPO.Tenant/UpdateTargetedSite.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@milanholemans : I get the following error with the AddHomeSite endpoint.
-vivaConnectionsDefaultStart
{"odata.error":{"code":"-1, Microsoft.SharePoint.Client.InvalidClientQueryException","message":{"lang":"en-US","value":"The parameter vivaConnectionsDefaultStart does not exist in
| method AddHomeSite."}}}
-isInDraftMode
{"odata.error":{"code":"-1, Microsoft.SharePoint.Client.InvalidClientQueryException","message":{"lang":"en-US","value":"The parameter isInDraftMode does not exist in method
| AddHomeSite."}}}
-siteUrl
{"odata.error":{"code":"-1, Microsoft.SharePoint.Client.InvalidClientQueryException","message":{"lang":"en-US","value":"The parameter siteUrl does not exist in method
| AddHomeSite."}}}

It seems to accept only the parameter homeSiteUrl.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I've tried some things as well, and didn't get it to work, unfortunately. It did work for the _api/SPHSite/AddHomeSite API request, I have no idea if there's any difference, but it seems to be working for me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@milanholemans : _api/SPHSite/AddHomeSite works with these 3 parameters: audiences, vivaConnectionsDefaultStart and isInDraftMode. I will amend the code to use _api/SPHSite/AddHomeSite and add these three parameters.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the _api/SPHSite/AddHomeSite API body, we can provide more options:

image

I think we can use all these options in this command. That would mean that we have to add them as input for the command. Sorry that we didn't figure this out when speccing the command.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@milanholemans : I will add order as well, out of curiosity where did you find information on this endpoint?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@milanholemans : thanks for sharing.

@milanholemans milanholemans marked this pull request as draft January 3, 2025 21:30
@reshmee011 reshmee011 marked this pull request as ready for review January 5, 2025 01:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

m365 spo homesite add
2 participants