Back to Collection Items
<?php
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
// For versions of Chilkat < 10.0.0, use new COM('Chilkat_9_5_0.Chilkat.Http')
$http = new COM("Chilkat.Http");
// Use this online tool to generate code from sample JSON: Generate Code to Create JSON
// The following JSON is sent in the request body.
// {
// "themeKey": "<string>"
// }
// For versions of Chilkat < 10.0.0, use new COM('Chilkat_9_5_0.Chilkat.JsonObject')
$json = new COM("Chilkat.JsonObject");
$json->UpdateString('themeKey','<string>');
// Adds the "Authorization: Bearer <access_token>" header.
$http->AuthToken = '<access_token>';
$http->SetRequestHeader('Content-Type','application/json');
// For versions of Chilkat < 10.0.0, use new COM('Chilkat_9_5_0.Chilkat.StringBuilder')
$sbRequestBody = new COM("Chilkat.StringBuilder");
$json->EmitSb($sbRequestBody);
// resp is a Chilkat.HttpResponse
$resp = $http->PTextSb('PUT','https://your-domain.atlassian.net/wiki/rest/api/space/:spaceKey/theme',$sbRequestBody,'utf-8','application/json',0,0);
if ($http->LastMethodSuccess == 0) {
print $http->LastErrorText . "\n";
exit;
}
// For versions of Chilkat < 10.0.0, use new COM('Chilkat_9_5_0.Chilkat.StringBuilder')
$sbResponseBody = new COM("Chilkat.StringBuilder");
$resp->GetBodySb($sbResponseBody);
// For versions of Chilkat < 10.0.0, use new COM('Chilkat_9_5_0.Chilkat.JsonObject')
$jResp = new COM("Chilkat.JsonObject");
$jResp->LoadSb($sbResponseBody);
$jResp->EmitCompact = 0;
print 'Response Body:' . "\n";
print $jResp->emit() . "\n";
$respStatusCode = $resp->StatusCode;
print 'Response Status Code = ' . $respStatusCode . "\n";
if ($respStatusCode >= 400) {
print 'Response Header:' . "\n";
print $resp->Header . "\n";
print 'Failed.' . "\n";
exit;
}
?>
Curl Command
curl -X PUT
-H "Authorization: Bearer <access_token>"
-H "Content-Type: application/json"
-d '{
"themeKey": "<string>"
}'
https://your-domain.atlassian.net/wiki/rest/api/space/:spaceKey/theme
Postman Collection Item JSON
{
"name": "Set space theme",
"request": {
"auth": {
"type": "oauth2"
},
"method": "PUT",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"themeKey\": \"<string>\"\n}"
},
"url": {
"raw": "{{baseUrl}}/api/space/:spaceKey/theme",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"space",
":spaceKey",
"theme"
],
"variable": [
{
"key": "spaceKey",
"value": "<string>",
"type": "string",
"description": "(Required) The key of the space to set the theme for."
}
]
},
"description": "Sets the theme for a space. Note, if you want to reset the space theme to\nthe default Confluence theme, use the 'Reset space theme' method instead\nof this method.\n\n**[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:\n'Admin' permission for the space."
},
"response": [
{
"name": "Returned if the theme was set for the space.",
"originalRequest": {
"method": "PUT",
"header": [
{
"description": {
"content": "Added as a part of security scheme: oauth2",
"type": "text/plain"
},
"key": "Authorization",
"value": "<token>"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"themeKey\": \"<string>\"\n}"
},
"url": {
"raw": "{{baseUrl}}/api/space/:spaceKey/theme",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"space",
":spaceKey",
"theme"
],
"variable": [
{
"key": "spaceKey"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{}"
},
{
"name": "Returned if the theme key is invalid.",
"originalRequest": {
"method": "PUT",
"header": [
{
"description": {
"content": "Added as a part of security scheme: oauth2",
"type": "text/plain"
},
"key": "Authorization",
"value": "<token>"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"themeKey\": \"<string>\"\n}"
},
"url": {
"raw": "{{baseUrl}}/api/space/:spaceKey/theme",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"space",
":spaceKey",
"theme"
],
"variable": [
{
"key": "spaceKey"
}
]
}
},
"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 key.",
"originalRequest": {
"method": "PUT",
"header": [
{
"description": {
"content": "Added as a part of security scheme: oauth2",
"type": "text/plain"
},
"key": "Authorization",
"value": "<token>"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"themeKey\": \"<string>\"\n}"
},
"url": {
"raw": "{{baseUrl}}/api/space/:spaceKey/theme",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"space",
":spaceKey",
"theme"
],
"variable": [
{
"key": "spaceKey"
}
]
}
},
"status": "Not Found",
"code": 404,
"_postman_previewlanguage": "text",
"header": [
{
"key": "Content-Type",
"value": "text/plain"
}
],
"cookie": [
],
"body": ""
}
]
}