Go to the table of contents Go to the previous page Go to the next page View or print as PDF
Interfaces > Examples using curl
Examples using curl
In addition to the examples below, you can download a tar file containing a series of sample Python scripts:
http://www.websense.com/content/support/library/web/v84/mgmt_api_guide/api_example_code.tar
The sample scripts demonstrate how administrators might automate use of the Management API.
Adding API-managed categories, URLs, and IP addresses
Start a new transaction:
curl -k -u <username>:<password> -X POST https://<ps_ip_address>:15873/api/web/v1/categories/start
Add an API-managed category (all data in the HTTPS request):
curl -k -u <username>:<password> -X POST https://<ps_ip_address>:15873/api/web/v1/categories -d "{\"Transaction ID\":\"<transaction_ID_string>\",\"Categories\": [ {\"Category Name\": \"<name_string>\",\"Category Description\":\"<description_string>\",\"Parent\": <numeric_category_ID>}]}"
Add API-managed categories (data in a JSON file):
curl -k -u <username>:<password> -X POST https://<ps_ip_address>:15873/api/web/v1/categories -d @<filename>.json --header "Content-Type: application/json"
Or:
curl -k -u <username>:<password> -X POST https://<ps_ip_address>:15873/api/web/v1/categories --upload-file /<path>/<filename>.json
Add a URL (all data in the HTTPS request):
curl -k -u <username>:<password> -X POST https://<ps_ip_address>:15873/api/web/v1/categories/urls -d "{\"Transaction ID\": \"<transaction_ID_string>\",\"Category ID\": <numeric_ID>,\"URLs\":[\"https://www.new_url.com/\"]}" --cacert PolApiServer.crt
Add URLs or IP addresses (data in a JSON file):
curl -k -u <username>:<password> -X POST https://<ps_ip_address>:15873/api/web/v1/categories/urls -d @<filename>.json --header "Content-Type: application/json"
Or:
curl -k -u <username>:<password> -X POST https://<ps_ip_address>:15873/api/web/v1/categories/urls --upload-file /<path>/<filename>.json
Commit the transaction:
curl -k -u <username>:<password> -X POST https://<ps_ip_address>:15873/api/web/v1/categories/commit?TransactionID="<id_string>"
Deleting API-managed categories, URLs, and IP addresses
Start a new transaction:
curl -k -u <username>:<password> -X POST https://<ps_ip_address>:15873/api/web/v1/categories/start
Delete an API-managed category:
curl -k -u <username>:<password> -X POST https:// <ps_ip_address>:15873/api/web/v1/categories/delete -d "{\"Transaction ID\":\"<transaction_ID_string>\",\"Category Names\":[\"<category_name>\"]}"
Or:
curl -k -u <username>:<password> -X POST https://<ps_ip_address>:15873/api/web/v1/categories/delete -d "{\"Transaction ID\":\"<transaction_ID_string>\",\"Category IDs\":[<category_ID>]}"
Delete URLs or IP addresses from an API-managed category:
curl -k -u <username>:<password> -X POST https://<ps_ip_address>:15873/api/web/v1/categories/delete/urls -d @<filename>.json --header "Content-Type: application/json"
Or:
curl -k -u <username>:<password> -X POST https://<ps_ip_address>:15873/api/web/v1/categories/delete/urls --upload-file /<path>/<filename>.json
Commit the transaction:
curl -k -u <username>:<password> -X POST https://<ps_ip_address>:15873/api/web/v1/categories/commit?TransactionID="<id_string>"
 

Go to the table of contents Go to the previous page Go to the next page View or print as PDF
Interfaces > Examples using curl
Copyright 2022 Forcepoint. All rights reserved.