I am trying to create a classic subweb using a POST REST call in SPFx. Any idea what I am doing wrong here?
const postURL: string = `${this.props.context.siteUrl}/_api/web/webinfos/add`;
const requestBody: any = {
'parameters': {
'__metadata': {
'type': 'SP.WebInfoCreationInformation'
},
'Url': this.props.context.siteUrl + '/' + title,
'Description': 'Subsite created from REST API',
'Title': title,
'Language': 1033,
'WebTemplate': 'B7A00BA4-AFDC-4E70-B137-10DAEBED4D8B#TemplateName',
'UseUniquePermissions': true
}
};
const requestHeaders: any = {
'Accept': 'application/json;odata=verbose',
'Content-type': 'application/json;odata=verbose',
'odata-version': '3.0',
"X-HTTP-Method": "POST"
};
const spOpts: ISPHttpClientOptions = {
headers: requestHeaders,
body: JSON.stringify(requestBody)
};
console.log("About to make REST API request.");
this.props.context.spHttpClient.post(
postURL,
SPHttpClient.configurations.v1,
spOpts);
Error message: Uncaught (in promise) SyntaxError: Unexpected end of JSON input