martexx
Member
When i try to upload a file i received in a pabbly email parser i get this error, only happens with the file url from pabbly.
Status Code: 417
Response Text: ERR: Expected hex 0x in '{0}'.
the same happens if i make it in a normal api call
Status Code: 417
Response Text: ERR: Expected hex 0x in '{0}'.
Python:
import requests
from urllib.parse import urlparse
# Set the filename manually or extract it from the URL
manual_filename = f'1. Subject : introductie Rianne2 {{pc_local_date_now}}.pdf'
# API URL for file upload
upload_url = 'https://private31527/ExternalApi/api/CrewingDocumentsContent/UploadFile'
# API headers
headers = {
'Accept': 'application/json',
'apiKey': '{{PrivateTransafeKey}}'
}
# Form data
data = {
'EntityID': '{{3. Result : RiannerIntroductieIDnr}}'
}
# File download URL (direct download link from Google Drive)
file_url = 'https://pcmailhook.com/attachments/2025/01/01/xxx562_03.10-Introduction-for--on--completed-on-.pdf'
# Download the file
file_response = requests.get(file_url)
if file_response.status_code == 200:
# Use the manually set filename
filename = manual_filename
# Prepare the file for upload
files = {'File': (filename, file_response.content)}
# Send the POST request to upload the file
response = requests.post(upload_url, headers=headers, data=data, files=files)
# Output the response
print(f"Status Code: {response.status_code}")
print(f"Response Text: {response.text}")
else:
print(f"Failed to download the file. Status code: {file_response.status_code}")
the same happens if i make it in a normal api call