for filename in os.listdir(path):
abs_file_path = os.path.abspath(filename)
if filename.endswith('.xliff'):
with open(abs_file_path,'r') as f:
try:
headers = {
'X-Requested-With': 'XMLHttpRequest',
'Content-Type': 'application/json',
'X-APTRINSIC-API-KEY': '7dbf1a7d-a030-4656-9cac-e664016b208b',
}
print(abs_file_path)
response = requests.post(post_path,files={abs_file_path:f})
response.raise_for_status()
print(response.status_code)
if response.status_code == 401:
files = {'file': open(abs_file_path, 'rb')}
response = requests.post(post_path,headers=headers, auth=HTTPBasicAuth(username,password),files=files)
if response.status_code != 200:
print("Upload NOT completed successfully!")
except requests.exceptions.HTTPError as errh:
print(errh)
except requests.exceptions.ConnectionError as errc:
print(errc)
except requests.exceptions.Timeout as errt:
print(errt)
except requests.exceptions.RequestException as err:
print(err)
Page 1 / 1
Reply
Sign up
If you ever had a profile with us, there's no need to create another one.
Don't worry if your email address has since changed, or you can't remember your login, just let us know at community@gainsight.com and we'll help you get started from where you left.
Else, please continue with the registration below.
Welcome to the Gainsight Community
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.