def _sendRequest(self, method, data): """Sends an API request to the server, returns a dictionary with the server's response. It should not need to be called explicitly by the user, but rather by the other functions. Keyword arguments: method -- name of the method being called. data -- parameters to the function being called, should be in a list sorted by order of items """ data = json.dumps(data) args = {'method': method, 'input_type': 'json', 'response_type' : 'json', 'rest_data' : data} params = urllib.urlencode(args) response = urllib.urlopen(self._url, params) response = response.read() result = json.loads(response) if is_error(result): raise SugarError(result) return result
def _sendRequest(self, method, data): """Sends an API request to the server, returns a dictionary with the server's response. It should not need to be called explicitly by the user, but rather by the other functions. Keyword arguments: method -- name of the method being called. data -- parameters to the function being called, should be in a list sorted by order of items """ data = json.dumps(data) args = { 'method': method, 'input_type': 'json', 'response_type': 'json', 'rest_data': data } params = urllib.urlencode(args) response = urllib.urlopen(self._url, params) response = response.read() result = json.loads(response) if is_error(result): raise SugarError(result) return result
def _sendRequest(self, method, data): """Sends an API request to the server, returns a dictionary with the server's response. It should not need to be called explicitly by the user, but rather by the other functions. Keyword arguments: method -- name of the method being called. data -- parameters to the function being called, should be in a list sorted by order of items """ data = json.dumps(data) args = {'method': method, 'input_type': 'JSON', 'response_type' : 'JSON', 'rest_data' : data} params = urllib.urlencode(args) response = urllib.urlopen(self._url, params) response = response.read().strip() if not response: raise SugarError({'name': 'Empty Result', 'description': 'No data from SugarCRM.', 'number': 0}) result = json.loads(response) # Added method != 'logout' because logout method in sugarcrm does not return anything if is_error(result): raise SugarError(result) return result