Open Samsinite opened 5 years ago
Got the sample invalid email? We can either do a basic regex validation (contains @) or a more complex RFC based one; but if it doesn't match the underlying API perfectly; it might be better to do the simplest approach.
Hey @Samsinite, a contact will always require a valid email if provided.
That appears to be the basis of this issue. An invoice relies on a valid contact, so that's going to fail if the contact is invalid.
I see two issues to fix here: 1) Contact model in wrapper is not validating email address, as mentioned by @CloCkWeRX 2) Validation error is not being caught an processed by the Contact record.
Here is what the API response looks like in this case (single invoice, single contact):
<ApiException xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ErrorNumber>10</ErrorNumber>
<Type>ValidationException</Type>
<Message>A validation exception occurred</Message>
<Elements>
<DataContractBase xsi:type="Invoice">
<ValidationErrors>
<ValidationError>
<Message>Email address must be valid.</Message>
</ValidationError>
</ValidationErrors>
<Contact>
<ValidationErrors>
<ValidationError>
<Message>Email address must be valid.</Message>
</ValidationError>
</ValidationErrors>
<ContactID>c344c7b4-3da8-4ec4-a54d-8407b3a359f0</ContactID>
<ContactStatus>ACTIVE</ContactStatus>
<Name>tester</Name>
<EmailAddress>notvalid.com@asdf</EmailAddress>
<Addresses>
<Address>
<AddressType>STREET</AddressType>
</Address>
<Address>
<AddressType>POBOX</AddressType>
</Address>
</Addresses>
<Phones>
<Phone>
<PhoneType>DEFAULT</PhoneType>
</Phone>
<Phone>
<PhoneType>DDI</PhoneType>
</Phone>
<Phone>
<PhoneType>FAX</PhoneType>
</Phone>
<Phone>
<PhoneType>MOBILE</PhoneType>
</Phone>
</Phones>
<UpdatedDateUTC>2021-09-23T00:34:40.7479588Z</UpdatedDateUTC>
<IsSupplier>false</IsSupplier>
<IsCustomer>false</IsCustomer>
</Contact>
<Date>2021-09-23T00:00:00</Date>
<Status>DRAFT</Status>
<LineAmountTypes>Exclusive</LineAmountTypes>
<LineItems>
<LineItem>
<Description>Test</Description>
<UnitAmount>10.00</UnitAmount>
<TaxType>OUTPUT</TaxType>
<TaxAmount>1.00</TaxAmount>
<LineAmount>10.00</LineAmount>
<Quantity>1.0000</Quantity>
<LineItemID>03296a58-c5f7-48ff-aa83-bdfe3102457c</LineItemID>
</LineItem>
</LineItems>
<SubTotal>10.00</SubTotal>
<TotalTax>1.00</TotalTax>
<Total>11.00</Total>
<CurrencyCode>AUD</CurrencyCode>
<Type>ACCREC</Type>
<InvoiceID>00000000-0000-0000-0000-000000000000</InvoiceID>
<InvoiceNumber>ORC1080</InvoiceNumber>
<AmountDue>11.00</AmountDue>
<AmountPaid>0.00</AmountPaid>
<SentToContact>false</SentToContact>
<CurrencyRate>1.0000000000</CurrencyRate>
<HasErrors>true</HasErrors>
</DataContractBase>
</Elements>
</ApiException>
Hi, we are encountering a validation error on a contact when batch creating a set of invoices, apparently this requires that the email address is valid if one is present. Was actually surprised to see this error as there was no associated error when we saved the contact model. Even stranger is that the validation error is nested under the contact even though that contact was already created. I have the response xml that I can likely provide (as long as I remove sensitive information) if that helps. I am going to dig into the request xml to see what was sent over.