Then I would highly suspect that the right way to do this is either:
1 -- Make sure the student is first enrolled in the course:
(1a) Enroll the student first in the course offering that is the parent of the target section.
(1b) Enroll the student in the appropriate section that's a child of the course offering.
2 -- Enroll the student directly in the section, using the full "enroll in org unit" call -- assign them a role, and identify the section's org unit ID and user's ID, rather than the enroll in section call.
Which of these methods you employ will likely depend on the needs of your organization, and the side-effects of enrolling users in place in your organization. For example, what roles you have set up to do cascading enrollments, whether your sections are set up to be auto-enrolled (i.e. student enrollments in the course are then auto-enrolled in groups or sections), or whether your sections must receive direct explicit enrollments of students, and so forth.