Hi Tom,
Yes the API is not documented. You can add the Report Settings using our API's as follows:
API : https://www.site24x7.com/api/customize_report?authtoken=<auth_token>
Method : POST
Form Data Parameters:
Logo-Image File(.jpg/.png/.gif) as attachment.
JSONString : JSONString as Text(Format given below)
JSONString -{"background_color":"#68AB42","foreground_color":"#ffffff","maintenance_required":false,"company_name":"my company name","email_address":"[email protected]"}
Since you are an MSP customer, you need to pass an additional Cookie Header "msp_zaaid". Kindly refer our API Help Doc for more details regarding API's for MSP Accounts.
Thanks,
Yamini
Hi Yamini,
What do you mean by JSONString? I get an error when I use this Python code:
def change_report():
payload = {
"background_color": "#ff9900",
"foreground_color": "#ffffff",
"maintenance_required": "true",
"company_name": "Cloudar",
"email_address": "[email protected]"
}
files = {'file': open('Cloudar_Logo.png', 'rb')}
print json.dumps(payload)
update_report = requests.post(report_url, data=json.dumps(payload), params=all_params, headers=all_headers)
data = update_report.json()
result = data['message']
print('...done! Result: {}'.format(result))
This gives me this output (files not attached yet):
Setting custom reports settings...
{"email_address": "[email protected]", "maintenance_required": "true", "background_color": "#ff9900", "company_name": "Cloudar", "foreground_color": "#ffffff"}
...done! Result: JSONString should occur at least once.
And this gives me an internal error:
def change_report():
payload = {
"background_color": "#ff9900",
"foreground_color": "#ffffff",
"maintenance_required": "true",
"company_name": "Cloudar",
"email_address": "[email protected]"
}
files = {'json': (None, json.dumps(payload), 'application/json; version=2.0'),
'file': (os.path.basename('Cloudar_Logo.png'), open('Cloudar_Logo.png', 'rb'), 'application/octet-stream')
}
print (files)
update_report = requests.post(report_url, files=files, params=all_params, headers=all_headers_no_json)
data = update_report.json()
result = data['message']
print (result)
print('...done! Result: {}'.format(result))
Hi Tom,
'JSONString' should be given as a form data to the API.
We have written a sample python file to test the reports api.
Kindly download the attachement ( report_api.zip ) and unzip it.
Edit the file 'report_api.py' and replace the <auth token> with yours.
Execute the python file and check whether the api is working.
Regards,
Sriram
Hi Tom,
'Logo' should be sent as a file attachement with the param name 'ImageFile'
I have rewritten the python script and attached.
Kindly download it and make the following changes :
#1 ) change the auth token to yours.
#2 ) change the '<full_path_to_logo_file_name>' to the path of logo file.
Execute the python script and check whether it is working.
Thanks,
Sriram
Has anything changed to this API? We are getting errors now when we run the script:
def change_report():
payload = {
"background_color": "#ff9900",
"foreground_color": "#ffffff",
"maintenance_required": "true",
"company_name": "Cloudar",
"email_address": "[email protected]"
}
formdata = {
'JSONString': ('', json.dumps(payload)),
'ImageFile': (os.path.basename('Cloudar_Logo.png'), open('Cloudar_Logo.png', 'rb'),
'application/octet-stream')
}
update_report = requests.post(report_url, files=formdata, headers=all_headers_no_json)
data = update_report.json()
result = data['message']
Hi Tom,
We checked for this Error at our end and it seems like the Authtoken you are using is not valid anymore or might be deleted. Please follow the below steps to generate a new authtoken, once generated, please try to use the same API again. In case, it still doesn't work, please drop us an email at [email protected].
Site24x7 Users: https://www.site24x7.com/help/api/#authentication
MSP End-Customers: https://www.site24x7.com/help/msp/getting-started-with-site24x7-api.html#create-authtoken
Regards,
Varun Modi
Site24x7