Delete Address object using SonicOS API
10/21/2022 2 People found this article helpful 316,013 Views
Description
SonicOS API provides an alternative to the SonicOS Command Line Interface (CLI) for configuring selected functions.
SonicOS API is disabled by default in SonicOS. Any attempt to access SonicOS API while it is disabled results in an HTTP 403 Forbidden error
. To use the SonicOS API, you must enable it, either through the SonicOS Management Interface or from the CLI.
This article only explains how to add an Address group and add address objects to it. Please follow these articles for additional assistance:
- Introduction to SonicOS API
- Creating Address Object and Address Group Object using SonicOS API cURL
- Adding Multiple Address Objects Using SonicOS API
- SonicOS API for adding Address group in Postman and cURL
- Add new address object to an existing group - SonicOS API
You are free to choose Swagger, Postman, Git bash, or any application that allows API calls. If you are using a Linux-based operating system, you can execute cURL from the terminal. Please refer to https://sonicos-api.sonicwall.com for the entire list.
Only the first part of this article would change, depending on the SonicWall model you use. Commands are the same for both Gen6 and Gen7 SonicWall devices.
For this article, I'm using Postman App and will be showing the commands to run on cURL for each step.
Resolution
Please enable the SonicOS API module in the SonicWall UI. For Gen 7: Enable SonicOS API Gen7 and for Gen 6: Enable SonicOS API Gen6
The above KB also has the steps on how to log in using API Applications.
Step 1: In order to delete the address object, the name is very important. You need to know the name in full.
cURL commands:
curl -L -X DELETE 'https://192.168.168.168/api/sonicos/address-objects/ipv4' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Basic YWRtaW46cGFzc3dvcmQ=' \
--data-raw '{
"address_objects": [
{
"ipv4": {
"name": "IPv4_LAN_Address"
}
}
]
}'
Step 2: Committing all the configurational changes made with APIs:
curl -k -X POST "https://192.168.188.200/api/sonicos/config/pending" -H "accept: application/Json"
CAUTION: If you miss performing the action in Step 2 and log out, you will lose all the configuration changes made in the current session.
Related Articles
Categories