17580 500 when posting to textile with json

Implements the following tickets (the commits also reflect this order):

1. https://community.openproject.org/work_packages/17580
2. https://community.openproject.org/work_packages/17439
3. https://community.openproject.org/work_packages/17440
`end` at 83, 4 is not aligned with `-> (env) {` at 81, 18 or `exclude: -> (env) {` at 81, 9