REST API lookandfeel JSON Input
Asked by Atlassian Admin:

Has anybody had any luck updating Lookandfeel via REST API - from Python.

I used the template from the API documentation and NULLED the values which could not be retrieved via a GET earlier.

However, I keep getting a JSON decode error, since no data is returned / the call fails (405)

Does anyone know why the call fails here?:

```
import requests
from requests.auth import HTTPBasicAuth
import json

url = "https://{myurl}/wiki/rest/api/settings/lookandfeel"

auth = HTTPBasicAuth("mymail", "myToken")

headers = {
  "Accept": "application/json",
  "Content-Type": "application/json"
}

payload = json.dumps( {
  "headings": {
    "color": "#172b4d"
  },
  "links": {
    "color": "#0052cc"
  },
  "menus": {
    "hoverOrFocus": {
      "backgroundColor": "#3572b0"
    },
    "color": "#333333"
  },
  "header": {
    "backgroundColor": "#0747A6",
    "button": {
      "backgroundColor": "#3572b0",
      "color": "#ffffff"
    },
    "primaryNavigation": {
      "color": "#ffffff",
      "highlightColor": None,
      "hoverOrFocus": {
        "backgroundColor": "#3572b0",
        "color": "#ffffff"
      }
    },
    "secondaryNavigation": {
      "color": "#333333",
      "highlightColor": "#0747A6",
      "hoverOrFocus": {
        "backgroundColor": "#3572b0",
        "color": "#ffffff"
      }
    },
    "search": {
      "backgroundColor": "rgba(0, 0, 0, 0.2)",
      "color": "#ffffff"
    }
  },
  "horizontalHeader": {
    "backgroundColor": "#f3f2f1",
    "button": {
      "backgroundColor": None,
      "color": None
    },
    "primaryNavigation": {
      "color": None,
      "highlightColor": "#b00b23",
      "hoverOrFocus": {
        "backgroundColor": None,
        "color": None
      }
    },
    "secondaryNavigation": {
      "color": None,
      "highlightColor": None,
      "hoverOrFocus": {
        "backgroundColor": None,
        "color": None
      }
    },
    "search": {
      "backgroundColor": None,
      "color": None
    }
  },
  "content": {
    "screen": {
      "background": "#FFFFFF",
      "backgroundAttachment": None,
      "backgroundBlendMode": None,
      "backgroundClip": None,
      "backgroundColor": "#FFFFFF",
      "backgroundImage": "none",
      "backgroundOrigin": None,
      "backgroundPosition": None,
      "backgroundRepeat": None,
      "backgroundSize": "auto",
      "layer": {
        "width": None,
        "height": None
      },
      "gutterTop": "default",
      "gutterRight": "default",
      "gutterBottom": "default",
      "gutterLeft": "default"
    },
    "container": {
      "background": "#FFFFFF",
      "backgroundAttachment": None,
      "backgroundBlendMode": None,
      "backgroundClip": None,
      "backgroundColor": "#FFFFFF",
      "backgroundImage": "none",
      "backgroundOrigin": None,
      "backgroundPosition": None,
      "backgroundRepeat": None,
      "backgroundSize": "auto",
      "padding": "0",
      "borderRadius": "0"
    },
    "header": {
      "background": "#FFFFFF",
      "backgroundAttachment": None,
      "backgroundBlendMode": None,
      "backgroundClip": None,
      "backgroundColor": "#FFFFFF",
      "backgroundImage": "none",
      "backgroundOrigin": None,
      "backgroundPosition": None,
      "backgroundRepeat": None,
      "backgroundSize": "auto",
      "padding": "0",
      "borderRadius": "0"
    },
    "body": {
      "background": "#FFFFFF",
      "backgroundAttachment": None,
      "backgroundBlendMode": None,
      "backgroundClip": None,
      "backgroundColor": "#FFFFFF",
      "backgroundImage": "none",
      "backgroundOrigin": None,
      "backgroundPosition": None,
      "backgroundRepeat": None,
      "backgroundSize": "auto",
      "padding": "0",
      "borderRadius": "0"
    }
  },
  "bordersAndDividers": {
    "color": "#cccccc"
  },
  "spaceReference": {}
} )

response = requests.request(
   "POST",
   url,
   data=payload,
   headers=headers,
   auth=auth
)

#print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")))
print(response.status_code)
```


Answers:
author: Dominic Lagger
body: Hi

The 405 HTTP response code usually means that the requested method (in this case, POST) is not allowed for the resource. There could be several reasons for this, but one common reason is that the user making the request does not have the necessary permissions to perform the action.

You should double-check the credentials used to authenticate the API request and make sure that the user account has the necessary permissions to update the Look and Feel of the wiki.

Also, it's worth noting that the payload you are sending in the request does not contain any data for the "spaceKey" or "key" parameters, which are required to identify the wiki for which you want to update the Look and Feel. [See documentation](https://developer.atlassian.com/cloud/confluence/rest/v1/api-group-settings/#api-wiki-rest-api-settings-lookandfeel-get)

Regards, Dominic

comments: author: Atlassian Admin
body: Hi Dominic,

Thanks a lot for the info, that was very helpful.

Best regards,

Peter


Tags: cloud

confluence-cloud