Refusal of baptism

My dad told me that he was struggling to find a priest in New York who was willing to baptize me as an infant.

The reason he was told that was because my parents did not get married in the church,but ultimately he ended up finding a priest who was more than happy to baptize me.

Is that really the case that a child can/should be baptized only if the parents had a sacremental marriage inside the church?