Azure / Microsoft365R

R SDK for interacting with Microsoft 365 APIs
Other
318 stars 45 forks source link

How do I create shared teams folder? #174

Open mladencucak opened 1 year ago

mladencucak commented 1 year ago

How to pass ah argument to: team$create_channel(teams_channel ) to make it a shared folder?

RPanczak commented 11 months ago

Hi @hongooi73

Would shared channels ever be an option for the create_channel method?

I can see in the docs that there is membership option to switch between standard or private but no info on shared ones. Thanks!

hongooi73 commented 9 months ago

The teams-shared-channels branch now lets you set membership="shared" to create a shared channel, let me know if it works.

RPanczak commented 9 months ago

Many thanks for working on that @hongooi73

Tested with

# needs specific branch!
# remotes::install_github("Azure/Microsoft365R@teams-shared-channels")

library(Microsoft365R)

team <- Microsoft365R::get_team(team_name = "Your team name here")

team$list_channels()

team$create_channel("test_shared", membership = "shared")

Channel has been created and is correctly set to shared type. However I also get an error:

Error in self$properties$displayName : 
  $ operator is invalid for atomic vectors
hongooi73 commented 9 months ago

I've pushed a fix. Can you try it now?

In general, debugging business-related features is hard for me since I don't have a work/school MS365 account. I'd be grateful for any help in this regard.

RPanczak commented 9 months ago

Thank you for the fix - all stayed the same so the channel gets created correctly and the same error message appears

hongooi73 commented 9 months ago

Trying to narrow it down here; does z <- team$create_channel("xyz", membership="shared") work? Ie, creating the channel but NOT printing it to the screen.

RPanczak commented 9 months ago

Yes! That creates channel correctly without error 💪

hongooi73 commented 9 months ago

Great! Can you tell me what z$properties is?

RPanczak commented 9 months ago

Sure thing - this is what i get:

raw(0)
attr(,"status")
[1] 202
hongooi73 commented 9 months ago

Ok, that means it was created properly, but the create op isn't returning the properties for the channel, like it should.

Just to confirm, you did install the latest commit from the team-shared-channel branch, yes? As of ~10-11 hours ago?

hongooi73 commented 9 months ago

Ok, it's more complicated than I thought....

If successful, this method returns a 201 Created response code and a channel object in the response body for a channel with a membershipType value of standard or private. For a channel with a membershipType value of shared, this method returns a 202 Accepted response code and a link to the teamsAsyncOperation.

So basically, the code succeeds in creating the channel, it just isn't waiting like it should to confirm the result.

hongooi73 commented 9 months ago

I've pushed a small change that will alert you when you're creating a shared channel. To retrieve it, wait a while and then use get_channel. This is simpler than waiting for the async operation to complete (which would in any case negate the point of it being asynchronous).

mladencucakSYN commented 8 months ago

Thanks for sorting this out, I already gave up on this :) !

RPanczak commented 7 months ago

Hi @hongooi73 Do you have any (even approximate) plan or timeline on when these changes could make it to main?