in backend-printing/helper/sap_client.py [0:0]
def _call_sap_api(self, url):
"""Call SAP ODATA APIs
Args:
url (strings): URL that contains the ODATA API name
Returns:
response: SAP ODATA API response
"""
try:
session = requests.Session()
# needs to be updated with better retry logic
if self.sap_hostname.startswith("https://"):
session.mount("https://", HTTPAdapter(max_retries=3))
elif self.sap_hostname.startswith("http://"):
session.mount("http://", HTTPAdapter(max_retries=3))
response_object = requests.get(
headers={"Accept": "application/json"},
url=url,
auth=HTTPBasicAuth(self.sap_user, self.sap_password),
verify=not self.skip_ssl_verification,
)
response_object.raise_for_status()
return json.loads(response_object.text)
except Exception as e:
raise Exception(f"Error occurred while calling SAP API: {e}")