Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

REST API lookandfeel JSON Input

Atlassian Admin
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 20, 2023

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)

 

1 answer

0 votes
Dominic Lagger
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 20, 2023

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

Regards, Dominic

Atlassian Admin
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 22, 2023

Hi Dominic, 

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

Best regards, 

Peter

Like Dominic Lagger likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events