Context. Grad-Rubin type methods are interesting candidates for reconstructing the force-free magnetic field of a solar coronal region. As input these methods, however, require the normal component B n of the field on the whole boundary of the numerical box and the force-free function α on the part of the boundary where B n > 0 (or B n < 0), while observations provide data only on its lower photospheric part. Moreover, they introduce an unpleasing asymmetry between the opposite polarity parts of the boundary, and certainly do not take full advantage of the available data on α. Aims. We address these issues resulting from observations. We present a possible way to supply the missing information about B n and α on the non-photospheric sides of the box, and to use more effectively the data provided by the measurements. Methods. We introduce the optimization-Grad-Rubin method (OGRM), which is in some sense midway between optimization methods and the standard Grad-Rubin methods. It is based on an iterative scheme in which the α used as a boundary condition is imposed to take identical values at both footpoints of any field line and to be as close as possible to the α provided by the measurements on the photosphere. The degree of "closeness" is measured by an "error functional" containing a weight function reflecting the confidence that can be placed on the observational data. Results. The new method is implemented in our code XTRAPOL, along with some technical improvements. It is thus tested for two specific choices of the weight function by reconstructing a force-free field from data obtained by perturbing in either a random or a non-random way boundary values provided by an exact solution.