Chilkat Online Tools

delphiDll / Atlassian Confluence Cloud / Update look and feel settings

Back to Collection Items

var
http: HCkHttp;
success: Boolean;
json: HCkJsonObject;
resp: HCkHttpResponse;
sbResponseBody: HCkStringBuilder;
jResp: HCkJsonObject;
respStatusCode: Integer;

begin
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

http := CkHttp_Create();

// Use this online tool to generate code from sample JSON: Generate Code to Create JSON

// The following JSON is sent in the request body.

// {
//   "headings": {
//     "color": "<string>"
//   },
//   "links": {
//     "color": "<string>"
//   },
//   "menus": {
//     "hoverOrFocus": {
//       "value": "<Error: Too many levels of nesting to fake this schema>"
//     },
//     "color": {
//       "value": "<Error: Too many levels of nesting to fake this schema>"
//     }
//   },
//   "header": {
//     "backgroundColor": {
//       "value": "<Error: Too many levels of nesting to fake this schema>"
//     },
//     "button": {
//       "value": "<Error: Too many levels of nesting to fake this schema>"
//     },
//     "primaryNavigation": {
//       "value": "<Error: Too many levels of nesting to fake this schema>"
//     },
//     "secondaryNavigation": {
//       "value": "<Error: Too many levels of nesting to fake this schema>"
//     },
//     "search": {
//       "value": "<Error: Too many levels of nesting to fake this schema>"
//     }
//   },
//   "content": {
//     "screen": {
//       "value": "<Error: Too many levels of nesting to fake this schema>"
//     },
//     "container": {
//       "value": "<Error: Too many levels of nesting to fake this schema>"
//     },
//     "header": {
//       "value": "<Error: Too many levels of nesting to fake this schema>"
//     },
//     "body": {
//       "value": "<Error: Too many levels of nesting to fake this schema>"
//     }
//   },
//   "bordersAndDividers": {
//     "color": "<string>"
//   }
// }

json := CkJsonObject_Create();
CkJsonObject_UpdateString(json,'headings.color','<string>');
CkJsonObject_UpdateString(json,'links.color','<string>');
CkJsonObject_UpdateString(json,'menus.hoverOrFocus.value','<Error: Too many levels of nesting to fake this schema>');
CkJsonObject_UpdateString(json,'menus.color.value','<Error: Too many levels of nesting to fake this schema>');
CkJsonObject_UpdateString(json,'header.backgroundColor.value','<Error: Too many levels of nesting to fake this schema>');
CkJsonObject_UpdateString(json,'header.button.value','<Error: Too many levels of nesting to fake this schema>');
CkJsonObject_UpdateString(json,'header.primaryNavigation.value','<Error: Too many levels of nesting to fake this schema>');
CkJsonObject_UpdateString(json,'header.secondaryNavigation.value','<Error: Too many levels of nesting to fake this schema>');
CkJsonObject_UpdateString(json,'header.search.value','<Error: Too many levels of nesting to fake this schema>');
CkJsonObject_UpdateString(json,'content.screen.value','<Error: Too many levels of nesting to fake this schema>');
CkJsonObject_UpdateString(json,'content.container.value','<Error: Too many levels of nesting to fake this schema>');
CkJsonObject_UpdateString(json,'content.header.value','<Error: Too many levels of nesting to fake this schema>');
CkJsonObject_UpdateString(json,'content.body.value','<Error: Too many levels of nesting to fake this schema>');
CkJsonObject_UpdateString(json,'bordersAndDividers.color','<string>');

// Adds the "Authorization: Bearer <access_token>" header.
CkHttp_putAuthToken(http,'<access_token>');
CkHttp_SetRequestHeader(http,'Content-Type','application/json');

resp := CkHttp_PostJson3(http,'https://your-domain.atlassian.net/wiki/rest/api/settings/lookandfeel/custom?spaceKey=<string>','application/json',json);
if (CkHttp_getLastMethodSuccess(http) = False) then
  begin
    Memo1.Lines.Add(CkHttp__lastErrorText(http));
    Exit;
  end;

sbResponseBody := CkStringBuilder_Create();
CkHttpResponse_GetBodySb(resp,sbResponseBody);

jResp := CkJsonObject_Create();
CkJsonObject_LoadSb(jResp,sbResponseBody);
CkJsonObject_putEmitCompact(jResp,False);

Memo1.Lines.Add('Response Body:');
Memo1.Lines.Add(CkJsonObject__emit(jResp));

respStatusCode := CkHttpResponse_getStatusCode(resp);
Memo1.Lines.Add('Response Status Code = ' + IntToStr(respStatusCode));
if (respStatusCode >= 400) then
  begin
    Memo1.Lines.Add('Response Header:');
    Memo1.Lines.Add(CkHttpResponse__header(resp));
    Memo1.Lines.Add('Failed.');
    CkHttpResponse_Dispose(resp);
    Exit;
  end;
CkHttpResponse_Dispose(resp);

CkHttp_Dispose(http);
CkJsonObject_Dispose(json);
CkStringBuilder_Dispose(sbResponseBody);
CkJsonObject_Dispose(jResp);

Curl Command

curl -X POST
	-H "Authorization: Bearer <access_token>"
	-H "Content-Type: application/json"
	-d '{
    "headings": {
        "color": "<string>"
    },
    "links": {
        "color": "<string>"
    },
    "menus": {
        "hoverOrFocus": {
            "value": "<Error: Too many levels of nesting to fake this schema>"
        },
        "color": {
            "value": "<Error: Too many levels of nesting to fake this schema>"
        }
    },
    "header": {
        "backgroundColor": {
            "value": "<Error: Too many levels of nesting to fake this schema>"
        },
        "button": {
            "value": "<Error: Too many levels of nesting to fake this schema>"
        },
        "primaryNavigation": {
            "value": "<Error: Too many levels of nesting to fake this schema>"
        },
        "secondaryNavigation": {
            "value": "<Error: Too many levels of nesting to fake this schema>"
        },
        "search": {
            "value": "<Error: Too many levels of nesting to fake this schema>"
        }
    },
    "content": {
        "screen": {
            "value": "<Error: Too many levels of nesting to fake this schema>"
        },
        "container": {
            "value": "<Error: Too many levels of nesting to fake this schema>"
        },
        "header": {
            "value": "<Error: Too many levels of nesting to fake this schema>"
        },
        "body": {
            "value": "<Error: Too many levels of nesting to fake this schema>"
        }
    },
    "bordersAndDividers": {
        "color": "<string>"
    }
}'
https://your-domain.atlassian.net/wiki/rest/api/settings/lookandfeel/custom?spaceKey=<string>

Postman Collection Item JSON

{
  "name": "Update look and feel settings",
  "request": {
    "auth": {
      "type": "oauth2"
    },
    "method": "POST",
    "header": [
      {
        "key": "Content-Type",
        "value": "application/json"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n    \"headings\": {\n        \"color\": \"<string>\"\n    },\n    \"links\": {\n        \"color\": \"<string>\"\n    },\n    \"menus\": {\n        \"hoverOrFocus\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        \"color\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        }\n    },\n    \"header\": {\n        \"backgroundColor\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        \"button\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        \"primaryNavigation\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        \"secondaryNavigation\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        \"search\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        }\n    },\n    \"content\": {\n        \"screen\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        \"container\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        \"header\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        \"body\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        }\n    },\n    \"bordersAndDividers\": {\n        \"color\": \"<string>\"\n    }\n}"
    },
    "url": {
      "raw": "{{baseUrl}}/api/settings/lookandfeel/custom?spaceKey=<string>",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "settings",
        "lookandfeel",
        "custom"
      ],
      "query": [
        {
          "key": "spaceKey",
          "value": "<string>",
          "description": "The key of the space for which the look and feel settings will be\nupdated. If this is not set, the global look and feel settings will\nbe updated."
        }
      ]
    },
    "description": "Updates the look and feel settings for the site or for a single space.\nIf custom settings exist, they are updated. If no custom settings exist,\nthen a set of custom settings is created.\n\nNote, if a theme is selected for a space, the space look and feel settings\nare provided by the theme and cannot be overridden.\n\n**[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:\n'Admin' permission for the space."
  },
  "response": [
    {
      "name": "Returned if the look and feel settings are updated.",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "description": {
              "content": "Added as a part of security scheme: oauth2",
              "type": "text/plain"
            },
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"headings\": {\n        \"color\": \"<string>\"\n    },\n    \"links\": {\n        \"color\": \"<string>\"\n    },\n    \"menus\": {\n        \"hoverOrFocus\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        \"color\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        }\n    },\n    \"header\": {\n        \"backgroundColor\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        \"button\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        \"primaryNavigation\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        \"secondaryNavigation\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        \"search\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        }\n    },\n    \"content\": {\n        \"screen\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        \"container\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        \"header\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        \"body\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        }\n    },\n    \"bordersAndDividers\": {\n        \"color\": \"<string>\"\n    }\n}"
        },
        "url": {
          "raw": "{{baseUrl}}/api/settings/lookandfeel/custom?spaceKey=<string>",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "settings",
            "lookandfeel",
            "custom"
          ],
          "query": [
            {
              "key": "spaceKey",
              "value": "<string>"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{}"
    },
    {
      "name": "Returned if;\n\n- The `spaceKey` is invalid\n- The request body contains invalid data.",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "description": {
              "content": "Added as a part of security scheme: oauth2",
              "type": "text/plain"
            },
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"headings\": {\n        \"color\": \"<string>\"\n    },\n    \"links\": {\n        \"color\": \"<string>\"\n    },\n    \"menus\": {\n        \"hoverOrFocus\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        \"color\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        }\n    },\n    \"header\": {\n        \"backgroundColor\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        \"button\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        \"primaryNavigation\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        \"secondaryNavigation\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        \"search\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        }\n    },\n    \"content\": {\n        \"screen\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        \"container\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        \"header\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        \"body\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        }\n    },\n    \"bordersAndDividers\": {\n        \"color\": \"<string>\"\n    }\n}"
        },
        "url": {
          "raw": "{{baseUrl}}/api/settings/lookandfeel/custom?spaceKey=<string>",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "settings",
            "lookandfeel",
            "custom"
          ],
          "query": [
            {
              "key": "spaceKey",
              "value": "<string>"
            }
          ]
        }
      },
      "status": "Bad Request",
      "code": 400,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    },
    {
      "name": "Returned if the calling user doesn't have permission to edit the\nlook and feel settings.",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "description": {
              "content": "Added as a part of security scheme: oauth2",
              "type": "text/plain"
            },
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"headings\": {\n        \"color\": \"<string>\"\n    },\n    \"links\": {\n        \"color\": \"<string>\"\n    },\n    \"menus\": {\n        \"hoverOrFocus\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        \"color\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        }\n    },\n    \"header\": {\n        \"backgroundColor\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        \"button\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        \"primaryNavigation\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        \"secondaryNavigation\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        \"search\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        }\n    },\n    \"content\": {\n        \"screen\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        \"container\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        \"header\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        \"body\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        }\n    },\n    \"bordersAndDividers\": {\n        \"color\": \"<string>\"\n    }\n}"
        },
        "url": {
          "raw": "{{baseUrl}}/api/settings/lookandfeel/custom?spaceKey=<string>",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "settings",
            "lookandfeel",
            "custom"
          ],
          "query": [
            {
              "key": "spaceKey",
              "value": "<string>"
            }
          ]
        }
      },
      "status": "Forbidden",
      "code": 403,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    },
    {
      "name": "Returned if there is no space with the given `spaceKey`.",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "description": {
              "content": "Added as a part of security scheme: oauth2",
              "type": "text/plain"
            },
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"headings\": {\n        \"color\": \"<string>\"\n    },\n    \"links\": {\n        \"color\": \"<string>\"\n    },\n    \"menus\": {\n        \"hoverOrFocus\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        \"color\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        }\n    },\n    \"header\": {\n        \"backgroundColor\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        \"button\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        \"primaryNavigation\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        \"secondaryNavigation\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        \"search\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        }\n    },\n    \"content\": {\n        \"screen\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        \"container\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        \"header\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        \"body\": {\n            \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        }\n    },\n    \"bordersAndDividers\": {\n        \"color\": \"<string>\"\n    }\n}"
        },
        "url": {
          "raw": "{{baseUrl}}/api/settings/lookandfeel/custom?spaceKey=<string>",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "settings",
            "lookandfeel",
            "custom"
          ],
          "query": [
            {
              "key": "spaceKey",
              "value": "<string>"
            }
          ]
        }
      },
      "status": "Not Found",
      "code": 404,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}