Cronjob or Scheduler not working if there is request.get

I have scheduler and cron job that is to fetch data from API in remote server.
When I try running bench execute it works but it is not working when I schedule it.

Below is the function

def fill_orders():
    #example API call
    x = requests.get('')
    doc = frappe.new_doc('Orders')
    doc.my_id = "Test ID"
    doc.channel_id = "XYZABC"

bench execute path_to.function.fill_orders works but when I left it in the schedule in the file, it fails. After commenting out the line with requests.get, it works again. Any help would be appreciated.

i am also facing this issue, if you find the solution can you share

Whitelist the function and try again

Hello everyone,

I faced the same issue where the Cronjob was not working when I used request.get method. After some investigation, I found the below solution that worked for me.

As a workaround, I used the http.client module to make the HTTP requests. Here’s an example of how I used it to send a GET request:

import http.client

conn = http.client.HTTPSConnection("")
conn.request("GET", "/")
response = conn.getresponse()
print(response.status, response.reason)
data =

This solution worked for me and I hope it helps others who are facing the same issue.