Hi! I wanted to post this bug report in the community portal, but I seems like I need additional permissions to do so, so I'll post my report there, since it's partially about spec too.
While doing the integration with xero I encountered an easily reproducible behavior that doesn't look correct, especially given that it behaves different for different content type.
Here is an xml payload:
<PurchaseOrders>
<PurchaseOrder>
<Contact>
<ContactID>BROKEN</ContactID>
</Contact>
<Date>2020-04-28T14:00:00</Date>
<LineAmountTypes>Exclusive</LineAmountTypes>
<LineItems>
<LineItem>
<Description>Coffee Cup</Description>
<Quantity>4.3400</Quantity>
<UnitAmount>395.00</UnitAmount>
<AccountCode>300</AccountCode>
</LineItem>
<DeliveryDate>2020-04-30</DeliveryDate>
<Reference>1234</Reference>
<DeliveryAddress>Hamburg</DeliveryAddress>
<AttentionTo>John Doe</AttentionTo>
<Telephone>+88885</Telephone>
</LineItems>
</PurchaseOrder>
</PurchaseOrders>
Since contact id is invalid I get a response with status 400 and body:
<ApiException xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ErrorNumber>14</ErrorNumber>
<Type>PostDataInvalidException</Type>
<Message>Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).</Message>
</ApiException>
If I switch to json and send a body like this:
{
"PurchaseOrders":
[
{
"Contact":
{
"ContactID":"BROKEN"
},
"LineItems":[
{"Description":"Tomatoes","Quantity":1,"ItemCode":"DevD"},
{"Description":"Potatoes","Quantity":1,"ItemCode":"GB1-White"},
{"Description":"Water","Quantity":1,"ItemCode":"PMD"}
],
"DeliveryDate":"2020-04-30",
"Reference":"1234",
"DeliveryAddress":"Hamburg",
"AttentionTo":"John Doe",
"Telephone":"+888885"
}
]
}
api responds with 500 status and body is never sent, hence a client that was generated base on openapi spec hangs forever. Given a correct account number the same payload works fine.
Unfotunately, json is the only format mentioned in the spec, so it's not possible to work it around by generating a client using a different content type.
One more note. It appears that purchase orders endpoint supports not only arrays but individual objects as well. So it's possible to send a payload like this:
{
"Contact":
{
"ContactID":"BROKEN",
"PaymentTerms":{"Bills":{},"Sales":{}},
"BatchPayments":{},
"Balances":{
"AccountsReceivable": {},"AccountsPayable":{}
}
},
"LineItems":[
{"Description":"Tomatoes","Quantity":1,"ItemCode":"DevD"},
{"Description":"Potatoes","Quantity":1,"ItemCode":"GB1-White"},
{"Description":"Water","Quantity":1,"ItemCode":"PMD"}
],
"DeliveryDate":"2020-04-30",
"Reference":"1234",
"DeliveryAddress":"Hamburg",
"AttentionTo":"John Doe",
"Telephone":"+888885"
}
In case of correct payload purchase orders are created, otherwise a correct error is returned:
{
"ErrorNumber": 14,
"Type": "PostDataInvalidException",
"Message": "JSON for post data was invalid,Error converting value \"BROKEN\" to type 'System.Guid'. Path 'Contact.ContactID', line 4, position 23."
}
Unfortunately this payload is not described in openapi and hence generated clients do not provide a way to submit this payload.
Expected behvaior: I would expect to get a 200 status code with an array of purchase orders. For the ones with incorrect account number I would expect to see an error as describe in the documentation:
If you are entering many purchase orders in a single API call then we recommend you utilise the summarizeErrors parameter which provides a response format that shows validation errors for each purchase order. Note that each Purchase Order is returned with a status element which will either contain the value OK or ERROR. If a purchase order has an error then one or more validation errors will be returned.