Handles conversion of the of the data into the appropriate format,
and sets the correct Content-Type header for our response.

@param string|array $body
@param string       $format Valid: json, xml

@return mixed
@throws \InvalidArgumentException If the body property is not string or array.