Site themes via Rest.

New Contributor

I tried following at



I keep getting the following response: 
<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<pre>Cannot POST /_api/thememanager/AddTenantTheme</pre>
3 Replies
const XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
const spauth = require("node-sp-auth");
const rp = require("request-promise");

const express = require("express");
const app = express();

const url = require("./config").url;
const credentialOptions = require("./config").credentialOptions;
const port = 80;

RestRequest = (url, params) => {
const _spPageContextInfo = url;
let req = new XMLHttpRequest();
req.onreadystatechange = function() {
if (req.readyState != 4)
// Loaded
};"POST", url, true);
req.setRequestHeader("Content-Type", "application/json;charset=utf-8");
req.setRequestHeader("ACCEPT", "application/json; odata.metadata=minimal");
req.setRequestHeader("x-requestdigest", _spPageContextInfo);
req.setRequestHeader("ODATA-VERSION", "4.0");
req.send(params ? JSON.stringify(params) : void 0);

const pal = {
palette: {
themePrimary: "#00ffff",
themeLighterAlt: "#f3fcfc",
themeLighter: "#daffff",
themeLight: "#affefe",
themeTertiary: "#76ffff",
themeSecondary: "#39ffff",
themeDarkAlt: "#00c4c4",
themeDark: "#009090",
themeDarker: "#005252",
neutralLighterAlt: "#f8f8f8",
neutralLighter: "#f4f4f4",
neutralLight: "#eaeaea",
neutralQuaternaryAlt: "#dadada",
neutralQuaternary: "#d0d0d0",
neutralTertiaryAlt: "#c8c8c8",
neutralTertiary: "#a6a6a6",
neutralSecondaryAlt: "#767676",
neutralSecondary: "#666666",
neutralPrimary: "#333",
neutralPrimaryAlt: "#3c3c3c",
neutralDark: "#212121",
black: "#000000",
white: "#fff",
primaryBackground: "#fff",
primaryText: "#333"

app.listen(port, () => {
console.log(`App listening on port ${port}`);

app.get("/", (req, res) => {
//get auth options
spauth.getAuth(url, credentialOptions).then(options => {
//perform request with any http-enabled library (request-promise in a sample below):
let headers = options.headers;
headers["Accept"] = "application/json;odata=verbose";

url: url,
headers: headers
}).then(response => {

RestRequest("/_api/thememanager/AddTenantTheme", {
name: "DPT Cyna",
themeJson: JSON.stringify(pal)
Not sure If I'm following you here...the URL you have provided refers to Site Designs REST API that is just to work with Site Designs and not with site work with themes using REST API take a look at this:

Sorry I apologize for providing the wrong article. I meant to provide the one you actually shared. I followed those instructions.