Hello there!
Thanks for all the resources in this discussion!
I have been struggling a bit with the results of a similar post in this community.
In my case, I can't seem to update (patch) or create (post) any configuration templates for my groups on Aruba Central.
1) Update an existing template.
I am using the following python code:
import requests
from pprint import pprint
group_name = 'home'
url = 'https://eu-apigw.central.arubanetworks.com/configuration/v1/groups/' + group_name + '/templates'
params = {"name":"initial_template",
"device_type":"CX",
"version":"ALL",
"model":"ALL"}
headers = {'Content-Type': 'application/json',
'Authorization': 'Bearer ' + access_token}
file = {"template": open('template_files/initial_template.txt', 'rb')}
response = requests.patch(url, headers=headers, files=file, params=params)
response_json = response.json()
pprint(response_json)
which returns a successful code:
$ python3 set_template.py
'Success'
And the template on Aruba Central updates its "last modified" attribute accordingly, but the changes are not in the template. The template in Aruba Central remains unchanged.
2) Creating a new template, using the same code but changing the template name and the HTTP method:
import requests
from pprint import pprint
group_name = 'home'
url = 'https://eu-apigw.central.arubanetworks.com/configuration/v1/groups/' + group_name + '/templates'
params = {"name":"initial_template2",
"device_type":"CX",
"version":"ALL",
"model":"ALL"}
headers = {'Content-Type': 'application/json',
'Authorization': 'Bearer ' + access_token}
file = {"template": open('template_files/initial_template.txt', 'rb')}
response = requests.post(url, headers=headers, files=file, params=params)
response_json = response.json()
pprint(response_json)
Which returns:
$ python3 set_template.py
{'detail': "Missing formdata parameter 'template'",
'status': 400,
'title': 'Bad Request',
'type': 'about:blank'}
even though I am using the 'template' key in the dict.
Any thoughts on any of those issues would be really appreciated!
Thanks!
------------------------------
Alex
------------------------------