XNAT-2992: Clean up handling of message parsing in REST API