MCPcopy Create free account
hub / github.com/GearPlug/dynamics365crm-python / parse_response

Method parse_response

dynamics365crm/client.py:72–116  ·  view source on GitHub ↗

This method get the response request and returns json data or raise exceptions :param response: :return:

(self, response)

Source from the content-addressed store, hash-verified

70 return self.make_request('patch', endpoint, data=data, json=json, **kwargs)
71
72 def parse_response(self, response):
73 """
74 This method get the response request and returns json data or raise exceptions
75 :param response:
76 :return:
77 """
78 if response.status_code == 204 or response.status_code == 201:
79 return True
80 elif response.status_code == 400:
81 raise Exception(
82 "The URL {0} retrieved an {1} error. Please check your request body and try again.\nRaw message: {2}".format(
83 response.url, response.status_code, response.text))
84 elif response.status_code == 401:
85 raise Exception(
86 "The URL {0} retrieved and {1} error. Please check your credentials, make sure you have permission to perform this action and try again.".format(
87 response.url, response.status_code))
88 elif response.status_code == 403:
89 raise Exception(
90 "The URL {0} retrieved and {1} error. Please check your credentials, make sure you have permission to perform this action and try again.".format(
91 response.url, response.status_code))
92 elif response.status_code == 404:
93 raise Exception(
94 "The URL {0} retrieved an {1} error. Please check the URL and try again.\nRaw message: {2}".format(
95 response.url, response.status_code, response.text))
96 elif response.status_code == 412:
97 raise Exception(
98 "The URL {0} retrieved an {1} error. Please check the URL and try again.\nRaw message: {2}".format(
99 response.url, response.status_code, response.text))
100 elif response.status_code == 413:
101 raise Exception(
102 "The URL {0} retrieved an {1} error. Please check the URL and try again.\nRaw message: {2}".format(
103 response.url, response.status_code, response.text))
104 elif response.status_code == 500:
105 raise Exception(
106 "The URL {0} retrieved an {1} error. Please check the URL and try again.\nRaw message: {2}".format(
107 response.url, response.status_code, response.text))
108 elif response.status_code == 501:
109 raise Exception(
110 "The URL {0} retrieved an {1} error. Please check the URL and try again.\nRaw message: {2}".format(
111 response.url, response.status_code, response.text))
112 elif response.status_code == 503:
113 raise Exception(
114 "The URL {0} retrieved an {1} error. Please check the URL and try again.\nRaw message: {2}".format(
115 response.url, response.status_code, response.text))
116 return response.json()
117
118 def url_petition(self, redirect_uri, resource):
119 if self.client_id is not None and redirect_uri is not None and resource is not None:

Callers 3

make_requestMethod · 0.95
exchange_codeMethod · 0.95
refresh_tokenMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected