I have created a flask application hosted on python anywhere, the app requests information from zoho using the request.json method. Which I beleive is causing the issue.
In Zoho i’ve used a Deluge script to access the application and map / put the lead fields.
I have tested some variations of the code where the fields which I am trying to request are hardcoded into the script. then when accessing the application through the python anywhere url it sucessfully runs the script.
I am unsure of the correct method to request the data from Zoho or opposingly how to provide the information to flask.
My errors are: “The method is not allowed for the requested URL.” or “Bad request” depending on what modifications I make.
`@app.route('/')
def generate_pdf():
# Receive data from Zoho CRM
data = request.json
lead_name = data['lead_name']
course_title = data['course_title']
official_course_title = data['official_course_title']
progression_plan = data['progression_plan']
start_date = data['start_date']
`
Assuming that the script itself is fine and the issue has been triangulated to the above this is my current python script to retrieve the information provided by my Deluge script.
Deluge script:
`url = "http://austinelephantcross.pythonanywhere.com/";
// Replace with your actual server URL
leadData = Map();
leadData.put("lead_name",input.lead_name);
leadData.put("course_title",input.course_title);
leadData.put("official_course_title",input.official_course_title);
leadData.put("progression_plan",input.progression_plan);
leadData.put("start_date",input.start_date);
response = postUrl(url,leadData,{"Content-Type":"application/json"});
info response.toString();
// This line logs the response for debugging
// Check for a successful response from your server
if(response.get("code") == 200)
{
return "PDF generation initiated successfully.";
}
else
{
return "Failed to initiate PDF generation. Please check the logs.";
}
`