Getting 404 Not Found Error When Updating Vacation Records via Zapier Code Step

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?

Zapier probably encodes request data differently than your local setup. Switch from data=json.dumps(vacation_update) to json=vacation_update in your requests call - it handles serialization automatically and usually fixes those weird 404s. Also, Zapier can mess up the input_data dictionary processing, so check you’re not getting empty strings instead of None values that could break your URL construction.

I’ve hit this exact problem with Zapier code steps. It’s usually how Zapier handles input variables vs your hardcoded local values. When you pull data from input_data.get(), one of those values is probably coming through as None or empty, which breaks your endpoint URL. Add some debug logging before your API call to see what’s actually getting passed: print(f"Debug - vacation_id: {vacation_id}, api_base: {api_base}"). This’ll show you if any critical values are missing. Also double-check your input mapping in the Zapier step - field names don’t always match what you expect. Watch out for trailing slashes in your API_BASE variable too. If your local script uses https://api.float.com/v3 but Zapier passes https://api.float.com/v3/, you’ll get a malformed URL that returns 404.

Check your input variable data types. Zapier probably converted your numeric IDs to strings, which breaks API endpoint construction silently. I’ve hit this exact issue before. The Float API likely expects integer vacation IDs but gets string values from Zapier’s parsing. Wrap your vacation_id in int() if it’s numeric, or use .strip() on strings to remove whitespace. Also verify your AUTH_TOKEN isn’t getting masked or cut off in Zapier’s environment - their logging hides sensitive data and makes debugging a pain. Hardcode one variable at a time in your Zapier code to find which input causes the 404. Since your local script works, the API credentials and endpoint are fine. This is definitely a data formatting problem between environments.