Inquiry: Batch/Bulk PATCH support for /rest/v3/devices
AnsweredDear Team,
We hope this message finds you well.
The purpose of this post is to inquire whether it is possible to update multiple camera names simultaneously through a single request in the NX API.
After reviewing the REST v3 (VMS 6.0+) documentation, we were unable to identify a method for bulk updates of camera names. In our solution, users can modify multiple camera names via the UI, and the server must apply these changes in NX. Performing individual PATCH requests to /rest/v3/devices/{id} for thousands of cameras would be inefficient, so we prefer a bulk method, even if chunking is required.
Please confirm if such a functionality exists or provide guidance on the most efficient approach.
Best regards.
-
Hi Miguel Dina,
You are on the right track using the
PATCH /rest/v3/devices/{id}endpoint; this is precisely the request needed for this task. To streamline the process, you can follow these steps:1. Retrieve Existing Device Data
First, you will need to identify the unique IDs of the devices you wish to rename. I recommend filtering the output to include only the essential fields:id,name, andurl(which contains the IP address). You can execute this via the following request:GET /rest/v4/devices?_format=CSV&_with=id,name,urlI have specified the
CSVformat here, as it is generally easier to manipulate in spreadsheet software of a simple text editor, compared to the default JSON or XML formats.
This request will generate a file nameddevices.csv.2. Prepare and Execute the Update
Once you have the file, you can simply update the "name" column with your preferred titles. After saving your changes, you can use a script to iterate through the CSV and send aPATCHrequest for each entry, replacing the{id}placeholder with the actual ID from your list with a loop.To assist with this, I have drafted a basic
.batscript which you can find HERE. It is designed as a starting point, so please feel free to adapt it to your specific environment or requirements.With kind regards.
0
Please sign in to leave a comment.
Comments
1 comment