@staticmethod
def _get_data_key(request, headers=None):
    """
        This method returns which key should be used when sending data through the requests library.
        A JSON request requires the "json" key while other requests require "data".

        :param request: (dict) a dictionary representing a request
        :param headers: (dict) a dictionary representing request headers
        :return: key to use when passing data to the requests library
        """
    if 'data' in request:
        return 'data'
    elif 'json' in request:
        return 'json'
    elif headers:
        return 'json' if headers.get('Content-Type'
            ) == 'application/json' else 'data'
    raise AssertionError(
        'Could not determine data_key for request {} or headers {}'.format(
        request, headers))
