Context. The planetary system discovered around the young A-type HR 8799 provides a unique laboratory to: a) test planet formation theories; b) probe the diversity of system architectures at these separations, and c) perform comparative (exo)planetology. Aims. We present and exploit new near-infrared images and integral-field spectra of the four gas giants surrounding HR 8799 obtained with SPHERE, the new planet finder instrument at the Very Large Telescope, during the commissioning and science verification phase of the instrument (July-December 2014). With these new data, we contribute to completing the spectral energy distribution (SED) of these bodies in the 1.0-2.5 µm range. We also provide new astrometric data, in particular for planet e, to further constrain the orbits. Methods. We used the infrared dual-band imager and spectrograph (IRDIS) subsystem to obtain pupil-stabilized, dual-band H2H3 (1.593 µm, 1.667 µm), K1K2 (2.110 µm, 2.251 µm), and broadband J (1.245 µm) images of the four planets. IRDIS was operated in parallel with the integral field spectrograph (IFS) of SPHERE to collect low-resolution (R ∼ 30), near-infrared (0.94-1.64 µm) spectra of the two innermost planets HR 8799 d and e. The data were reduced with dedicated algorithms, such as the Karhunen-Loève image projection (KLIP), to reveal the planets. We used the so-called negative planets injection technique to extract their photometry, spectra, and measure their positions. We illustrate the astrometric performance of SPHERE through sample orbital fits compatible with SPHERE and literature data. Results. We demonstrated the ability of SPHERE to detect and characterize planets in this kind of systems, providing spectra and photometry of its components. The spectra improve upon the signal-to-noise ratio of previously obtained data and increase the spectral coverage down to the Y band. In addition, we provide the first detection of planet e in the J band. Astrometric positions for planets HR 8799 bcde are reported for the epochs of July, August, and December 2014. We measured the photometric values in J, H2H3, K1K2 bands for the four planets with a mean accuracy of 0.13 mag. We found upper limit constraints on the mass of a possible planet f of 3-7 M Jup . Our new measurements are more consistent with the two inner planets d and e being in a 2d:1e or 3d:2e resonance. The spectra of HR 8799 d and e are well matched by those of L6-8 field dwarfs. However, the SEDs of these objects are redder than field L dwarfs longward of 1.6 µm.