Aims. Our aim is to confirm the interstellar detection of cyanic acid, HOCN, in the Galactic center clouds. It has previously been tentatively detected only in Sgr B2(OH). Methods. We used a complete line survey of the hot cores Sgr B2(N) and (M) in the 3 mm range, complemented by additional observations carried out with the IRAM 30 m telescope at selected frequencies in the 2 mm band and towards four additional positions in the Sgr B2 cloud complex in the 2 and 3 mm bands. The spectral survey was analysed in the local thermodynamical equilibrium approximation (LTE) by modeling the emission of all identified molecules simultaneously. This allowed us to distinguish weak features of HOCN from the rich line spectrum observed in Sgr B2(N) and (M). Lines of the more stable (by 1.1 eV) isomer isocyanic acid, HNCO, in these sources, as well as those of HOCN and HNCO towards the other positions, were analysed in the LTE approximation as well. Results. Four transitions of HOCN were detected in a quiescent molecular cloud in the Galactic center at a position offset in (RA, Dec) by (20 , 100 ) from the hot core source Sgr B2(M), confirming its previous tentative interstellar detection. Up to four transitions were detected toward five other positions in the Sgr B2 complex, including the hot cores Sgr B2(M), (S), and (N). A fairly constant abundance ratio of ∼0.3−0.8% for HOCN relative to HNCO was derived for the extended gas components, suggesting a common formation process of these isomers.