If you are creating a new volume from scratch you need to create and initialize the vtkImageData as well as the vtkMRML nodes.
Here’s a fully worked out example in this postNRRD method which starts from a nrrd file in memory but it should give you the info you need to adapt to your use case.