This is the code I am trying to execute :-
import fetch from 'node-fetch';
const siteUrl = 'url';
const libraryName = 'Pages';
const pageData = {
'__metadata': { 'type': 'SP.Publishing.ReusableHTMLItem' }, 'Title': 'New Page Title', 'LayoutWebpartsContent': '<div>Page Content Goes Here</div>', 'Publish': true
};
const headers = {
'Accept': 'application/json;odata=verbose',
'Content-Type': 'application/json;odata=verbose', 'Authorization': 'Access Token'
};
fetch(`${siteUrl}/_api/web/lists/getbytitle('${libraryName}')/AddValidateUpdateItemUsingPath()`,
{
method: 'POST',
headers: headers,
body: JSON.stringify(pageData)
})
.then(response => {
if (response.status === 201) {
console.log('Page created successfully.');
} else {
console.error('Page creation failed.');
} })
.catch(error => {
console.error('Error:', error);
});
Need a way to get the Access token for the Authorization for header without Azure AD or Username and password.
Or Else need another way to create a page in a SharePoint using Rest API without Azure AD or Username and password.
Or Else please provide the link or documentation Which says It's not possible to get Authorization for header without Azure AD or Username and password.