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)
REST API Post is not working
Userlevel 2
Reply
Login to the community
Enter your username or e-mail address. We'll send you an e-mail with instructions to reset your password.