Hello all,
I was looking through the REST API documentation and see I can retrieve a privacy mask details from a camera, but I don’t see a post method available to enable/disable it. We have a use case where we need to turn a privacy mask on and off and want to do it programmatically, either through a rule (doesn’t look possible) or via an API call triggered from an external system.
Does anybody know if this is possible?
Thank you!
It is possible. I think something is missing in the documentation because I think there should be something to show how to do this. Not finding it in documentation I had an idea that I should be able to replace GET with PATCH..
I made a mask on a camera to be able to see something. Then I used a GET (and this is documented here).
I then extracted the “enabled” field and used it, modified, as body in a PATCH.
It looks like this in Postman
Further information from my testing.
A POST is not possible, but it actually makes sense in that for a given camera there is always a privacyProtection (and you shouldn’t be able to create a duplicate). The GUID of the privacyProtection is always the same as the GUID of the camera.
One observation that puzzled me: If you do a GET /cameras/{id}/privacyProtections, then if enabled is false and privacyMaskXml is empty you will get a empty response. You do however get the data if you do a GET /cameras/{id}/privacyProtections/{id} or GET /privacyProtections/{id}
I have demonstrated a PATCH, but a PUT is also possible, it requires then that the “privacyMaskXml” is in the request body, if it is missing you will actually get a meaningful error saying it is missing.