Please specify what version of the library you are using: [ 1.26 ]
Please specify what version(s) of SharePoint you are targeting: [ spo ]
If you are not using the latest release, please update and see if the issue is resolved before submitting an issue.
A communication site should be created with the params i gave it.
It doesn't create the coms site and returns
{ Create:
{ __metadata: { type: 'Microsoft.SharePoint.Portal.SPSiteCreationResponse' },
SiteStatus: 3,
SiteUrl: '' } }
I set up SharePoint config, then I create a coms site by passing through the parameters it's asking for I press run, it tells me the site is created, I go to the URL i assigned the site and no site:(
I tried it with the below code and it works.
// using @pnp/sp
import { sp } from "@pnp/sp";
sp.site.createCommunicationSite("Comm Site Title",1033,true,"https://<tenant>.sharepoint.com/sites/commsiteTitle").then(d => {
console.log(d);
});
I tried it with the below code and it works.
// using @pnp/sp import { sp } from "@pnp/sp"; sp.site.createCommunicationSite("Comm Site Title",1033,true,"https://<tenant>.sharepoint.com/sites/commsiteTitle").then(d => { console.log(d); });
I just copied that, and changed my tenant to my tenant and still im getting the exact same back and no created site
Any chance you have a site with the same URL in the recycle bin ? Can you try with changing URL and then trying ? I tried it in the SP Editor console and SPFx webpart and it works on both these.
This is a brand new demo site :/
@gautamdsheth do you know if its possible to get the access token from the sp.setup?
How do I reproduce this issue ? Are you on a SharePoint page, because if you are then you don't need access token ?
I am using a serverless function(Node server), which takes some params and then uses those to create a site
Did you setup the config correctly as per this link on SP-Fetch-client ? You can also take a look at this blog where PnPJS is implemented in Azure functions.
@KieranDaviesV this errormessage you receive could either be that the URL is reserved, for some reason. Site in recycle bin etc.
Or it could be some underlying error at microsoft. Here you have the same error in PnPPowerShell.
https://github.com/SharePoint/PnP-PowerShell/issues/1542
Do you have the SP Editor so you could try from the console, in Chrome? Just to make sure there's no different behaviour in just the Function.
And if nothing is working, I do believe you have to create a ticked with Microsoft :(
Did you setup the config correctly as per this link on SP-Fetch-client ? You can also take a look at this blog where PnPJS is implemented in Azure functions.
Yeah, I have set it up correctly, as I can use other functions.
@KieranDaviesV this errormessage you receive could either be that the URL is reserved, for some reason. Site in recycle bin etc.
Or it could be some underlying error at microsoft. Here you have the same error in PnPPowerShell.
SharePoint/PnP-PowerShell#1542Do you have the SP Editor so you could try from the console, in Chrome? Just to make sure there's no different behaviour in just the Function.
And if nothing is working, I do believe you have to create a ticked with Microsoft :(
I tried it using the PowerShell and low and behold it created the site. After doing a lot of digging I've found people getting similar errors dating back quite a few months and it doesn't look like much as been resolved.
Looks like I'm gonna have to get in contact with Microsoft, thanks for all the help
Going to close this as answered and seems to be external to the library. Best of luck getting things sorted. Thanks!
Just gonna add a comment so if any has a similar issue they'll know. Apparently, you can't create a coms site without user context, which I guess made sense why it didn't work.
So to create coms sites on a server you need to get a user access token. i did this by using a native aad principle and then a username password login to get the access token. I hope this might help anyone
@KieranDaviesV Yeah that's right. I didn't even think about that :)
Creating a Site Collection via PnPPowershell you need to use User Credentials, if you use app credentials it doesn't work.
@KieranDaviesV Yeah that's right. I didn't even think about that :)
Creating a Site Collection via PnPPowershell you need to use User Credentials, if you use app credentials it doesn't work.
Exactly, very annoying that this isn't clearly documented but hopefully this can help someone else out!