I’m trying to modify vacation records through a Zapier automation but keep getting a 404 error. The weird thing is that my local Python script works perfectly fine, but the same logic fails when I run it through Zapier’s code functionality.
Local script that works:
import requests
import json
TOKEN = 'my_secret_token'
API_BASE = 'https://api.float.com/v3'
STAFF_ID = '5678'
START_DAY='2024-02-15'
END_DAY='2024-02-25'
VACATION_ID = '456'
DAILY_HOURS='8'
vacation_update = {
'vacation_id': VACATION_ID,
'begin_date': START_DAY,
'finish_date': END_DAY,
'vacation_notes': 'Modified holiday request',
'staff_ids': [STAFF_ID],
'daily_hours': DAILY_HOURS
}
api_endpoint = f"{API_BASE}/vacations/{VACATION_ID}"
request_headers = {
'Authorization': f"Bearer {TOKEN}",
'Content-Type': 'application/json'
}
try:
result = requests.patch(api_endpoint, headers=request_headers, data=json.dumps(vacation_update))
result.raise_for_status()
response_data = result.json()
print(f"Successfully updated vacation ID {VACATION_ID}:")
print(json.dumps(response_data, indent=2))
except requests.exceptions.HTTPError as error:
print(f"Request failed: {error}")
except Exception as error:
print(f"Something went wrong: {error}")
Zapier version that fails:
import requests
import json
vacation_id = input_data.get('VACATION_ID')
begin_date = input_data.get('BEGIN_DATE')
finish_date = input_data.get('FINISH_DATE')
staff_id = input_data.get('STAFF_ID')
daily_hours = input_data.get('DAILY_HOURS')
auth_token = input_data.get('AUTH_TOKEN')
api_base = input_data.get('API_BASE')
vacation_update = {
'vacation_id': vacation_id,
'begin_date': begin_date,
'finish_date': finish_date,
'vacation_notes': 'Modified holiday request',
'staff_ids': [staff_id],
'daily_hours': daily_hours
}
api_endpoint = f"{api_base}/vacations/{vacation_id}"
request_headers = {
'Authorization': f"Bearer {auth_token}",
'Content-Type': 'application/json'
}
print(f"Sending update: {vacation_update}")
print(f"To endpoint: {api_endpoint}")
try:
result = requests.patch(api_endpoint, headers=request_headers, data=json.dumps(vacation_update))
result.raise_for_status()
response_data = result.json()
return {'success': response_data}
except requests.exceptions.HTTPError as error:
failure_msg = f"Request failed: {error}"
print(failure_msg)
return {'failure': failure_msg}
except Exception as error:
failure_msg = f"Something went wrong: {error}"
print(failure_msg)
return {'failure': failure_msg}
The error I get shows that it can’t find the resource even though the same ID works locally. Has anyone run into this before? What could be different between running the code locally versus in Zapier?