Hi !
I’m trying to create a project to manage custom theme via the API. Everything works well except one thing.
I can’t rename a data file inside a theme. To be simpler I created python script functions to handle the API.
Below my function to call the ‘Update theme data file’ request
def updateThemeDataFile(name, filename, signature, content, rename = None):
""" Send a request to create/update a data file in a custom theme
Parameters
----------
name: str
Custom theme name
filename: str
Custom theme filename
signature: str
Custom theme last signature
content: str
Content for the file create or updated
rename: str, default = None
If True, rename the data file with the new name
Returns
-------
HttpResponse
The request's response
"""
httpClient = system.net.httpClient()
data = content
params = {
"signature": signature
}
if rename is not None:
params["rename"] = str(rename)
headers = {
"X-Ignition-API-Token": API.Common.APIKey
}
response = httpClient.put(
url = API.Common.baseUrl + "/data/api/v1/resources/datafile/com.inductiveautomation.perspective/themes/" + name + "/" + filename,
params = params,
data = data,
headers = headers
)
return response
Here the result returned by the http request in the designer script console. But the file name is not changed.
response = API.Themes.updateThemeDataFile(name = "custom", filename = "file.css", signature = "d9ba3650e5b55d326cb019bbeba00b70d140a2dc424f928be6c240cce2b3d96e", content = "content", rename = "file2.css")
print(response.getText())
{
"success": true,
"changes": [
{
"name": "custom",
"type": "com.inductiveautomation.perspective/themes",
"collection": "core",
"newSignature": "b3ad1966ad9ce46768e08f6943e380d15f6e832e605bf92d9a870e37a7d5a8c9"
}
],
"problem": null
}
I think this is a bug, but maybe I did something wrong.
Thank you