Mark for transaction rollback after APIException occurs.

Superseeds #1204.

Could do with either an integration test, or a nice clear example from someone of currently failing behaviour with steps to replicate.