'Attempt to encode JSON and XML automatically.'

def _to_content_type(self, body, headers, content_type=None):

    content_type = (content_type or self.content_type)
    if (content_type == 'json'):
        headers['Accept'] = 'application/json'
        if body:
            headers['Content-Type'] = 'application/json'
            return jsonutils.dump_as_bytes(body)
