Couldn't Get Call Resources. Error: input.replace ...
# support
v
@Michael P It seems like there might be an issue with the data payload format you're sending in your request. The error message "input.replace is not a function" suggests that the server expects a string where it is receiving a different type, possibly an object or an array. To help you further, I would need to see the actual Python code you're using to make the request, as there might be a discrepancy between how you're formatting the payload in Python and how it's represented in the cURL example you provided. However, if you're confident that the payload is correctly formatted in your Python code, this could be an issue on the server side that you wouldn't be able to fix on your own. In that case, I would recommend reaching out to VAPI support with the details of the request you're making and the exact error message you're receiving for further assistance. If you'd like, you can provide me with the Python code snippet you're using to make the POST request, and I can take a look to see if there are any apparent issues with it.
You can continue this conversation by mentioning me in the message.
m
@Vapi Here is the Python code that I am using: payload = { "assistantOverrides": { "variableValues": { "first_name": first_name, "last_name": last_name, "customer_id": customer_id #"caller_context": caller_context } }, "assistantId": assistant_id, "phoneNumberId": phone_id } # Make the API call to VAPI api_url = f"https://api.vapi.ai/call/" headers = { "Content-Type": "application/json", "Authorization": f"Bearer {VAPI_API_KEY}" } response = requests.post(api_url, headers=headers, json=payload) if response.status_code in [200, 204]: debug_print("Dynamic variables set successfully in VAPI.") return '', 200 else: debug_print(f"Failed to set variables in VAPI: {response.status_code} - {response.text}") return '', 500
v
@Michael P Your Python code looks correct in terms of structure and the way you're sending the request. The error you're encountering, "input.replace is not a function," is unusual because it implies that the server is expecting a string and is attempting to call the
replace
method on it, but is instead receiving a different type. Here are a few steps you can take to troubleshoot this issue: 1. **Check Variable Types**: Ensure that
first_name
,
last_name
, and
customer_id
are all strings. If any of these variables are not strings, you should convert them to strings before including them in the payload. 2. **Inspect Payload Before Sending**: Print out the
payload
just before sending the request to ensure it's formatted as expected. 3. **Headers and Payload**: Double-check that the headers are set correctly and that the
VAPI_API_KEY
variable contains the correct token. 4. **API Endpoint**: Verify that the API endpoint you're hitting is correct and that it's expecting the payload in the format you're sending. 5. **Contact Support**: Since the error message you're receiving is not documented and is not clear from the client-side perspective, it might be a good idea to contact VAPI support with the details of your request and the error message. Here's an example of how you can print the payload for inspection:
Copy code
python
import json

# ... [your existing code] ...

# Print the payload for inspection
print("Payload being sent:", json.dumps(payload, indent=2))

response = requests.post(api_url, headers=headers, json=payload)

# ... [your existing code] ...
If after these checks the issue still persists, please reach out to VAPI support for more detailed assistance.
@Michael P Sweet. Have a great day!
@Vapi Sweet. Have a great day!
8 Views