Go to All Forums

Update Report Settings through API

I am creating a script to configure new MSP customer accounts with our standard default values. One thing I would like to add is the Report Settings. What API calls are available? I searched through the docs, but could not find anything.



Reply 1
Replies (12)

Re: Update Report Settings through API

There must be an API call to do this, as it is configurable through the web GUI... 

Reply 0

Re: Re: Update Report Settings through API

Hi Tom,

Yes the API is not documented. You can add the Report Settings using our API's as follows:

APIhttps://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":"support@abc.com"}

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

 

Reply 2

Re: Re: Re: Update Report Settings through API

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": "support@cloudar.be"
}
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": "support@cloudar.be", "maintenance_required": "true", "background_color": "#ff9900", "company_name": "Cloudar", "foreground_color": "#ffffff"}
...done! Result: JSONString should occur at least once.


Reply 0

Re: Re: Re: Re: Update Report Settings through API

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": "support@cloudar.be"
}
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))
Reply 0

Re: Re: Re: Re: Update Report Settings through API

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

 

Attachments
report_api.zip
Size: 0.6 KB
Reply 0

Re: Re: Re: Re: Re: Update Report Settings through API

Hi Sriram,

That works great! Thanks. One more thing though, how do we set the logo at the same time?

Thanks,

Tom

Reply 0

Re: Re: Re: Re: Re: Re: Update Report Settings through API

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

 

Attachments
report_api.zip
Size: 0.68 KB
Reply 1

Re: Re: Re: Re: Re: Re: Re: Update Report Settings through API

Perfect! Thanks a lot!

Reply 0

Re: Re: Re: Re: Re: Re: Re: Re: Update Report Settings through API

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": "xxx@cloudar.be"
}
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']

 

Reply 0

Re: Re: Re: Re: Re: Re: Re: Re: Re: Update Report Settings through API

Hi Tom,

 

Can you please share the error that you are getting. It would be useful for us to analyze the issue and assist you further.

 

- Sriram

Reply 0

Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Update Report Settings through API

Hi Sriram,

 

The error is this:

Setting custom reports settings...
...done! Result: Not Found

Kind regards,

Tom

Reply 0

Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Update Report Settings through API

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 support@site24x7.com.

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

 

Reply 0