Payment Reminder - No contacts for the customer

Payment Reminder - No contacts for the customer

I create my invoices and then send them using the API. I also have reminders set up. I make sure that each customer has a primary contact, also with the API. But for about half the invoices I send I get an error message mailed to me because a contact isn't assigned to the invoice. As far as I can tell each customer is set up the same, but some randomly seem to work and others do not. Is there any way I can ensure that the primary contact is assigned to the invoice when it is created via the API?