def _request(
        self, uri=None, name=None, method=None, payload=None, headers=None,
        params=None
    ):
        """
        Wrapper for making a request to an API endpoint, either by name or uri.

        Args:
            uri: The path to the endpoint (sans domain). Optional if name used.
            name: The name of the endpoint. Optional if uri used.
            method: The http method to use. Generally optional.
            payload: A json-encodable object to include in the request body
            headers: Additional headers to provide for request. Optional;
                Authorization header will automatically be included.
            params: A dict of parameters to include in the GET query string.

        Returns:
            Either the json from the response body, if possible, or the
            full response if no json-decodable body is returned.
        """

        if uri is None and name is not None:
            uri = self.schema_uri_by_name[name]
            if method is None and name.startswith('get_'):
                method = 'get'

        if method is None:
            if payload is not None:
                method = 'post'
            else:
                method = 'get'
        method = method.lower()  # in case one was passed in uppercase

        if headers is None:
            headers = {}
        if self.authorization:
            headers['authorization'] = self.authorization

        if params is None:
            params = {}

        if payload is None:
            payload = {}

        #if we have an org id, try to include it in the params or payload
        if self.org_id and uri not in self.no_org_uris:
            if method == 'get':
                if 'organization_id' not in params:
                    params['organization_id'] = self.org_id
            else:
                if 'organization_id' not in payload:
                    payload['organization_id'] = self.org_id

        # json serialization of payload
        if payload:
            if not isinstance(payload, basestring):
                payload = json.dumps(payload)

        fn = getattr(requests, method)
        _url = self.base_url + uri

        response = fn(_url, data=payload, params=params, headers=headers)

        try:
            return response.json()
        except json.JSONDecodeError:
            return response
dataset/ETHPy150Open buildingenergy/buildingenergy-platform/seed/utils/api_client.py/APIClient._request/original